Enforce single H1 in docs notebooks (#863) + add pr-review skill#864
Closed
drbenvincent wants to merge 1 commit intomainfrom
Closed
Enforce single H1 in docs notebooks (#863) + add pr-review skill#864drbenvincent wants to merge 1 commit intomainfrom
drbenvincent wants to merge 1 commit intomainfrom
Conversation
…skill Closes #863 by extending scripts/validate_notebooks.py with a single-H1 check scoped to docs/source/notebooks/. The check ignores code cells and fenced code blocks inside markdown cells, so Python comments cannot trigger false positives. Tests cover valid notebooks, multi-H1 / no-H1 violations, code-cell comments, fenced-code-block comments, the out-of-scope exemption, and a regression test that walks every shipped docs notebook. Also adds a new .github/skills/pr-review/ skill — orchestrator SKILL.md plus six focused reference files — capturing the review patterns distilled from the PR #826 review iteration: workflow, severity-sorted look-fors, CausalPy code conventions, docs/notebook conventions, comment-drafting templates, and an extension/pruning protocol. Made-with: Cursor
Collaborator
Author
|
Closing in favour of a properly-scoped PR — this branch and PR conflated the #863 hook with the unrelated pr-review skill. Skill-only PR is being opened from |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #864 +/- ##
==========================================
- Coverage 94.60% 94.60% -0.01%
==========================================
Files 80 80
Lines 12764 12816 +52
Branches 770 772 +2
==========================================
+ Hits 12076 12124 +48
- Misses 485 487 +2
- Partials 203 205 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related-but-distinct changes bundled in one PR.
1. Single-H1 hook for docs notebooks (closes #863)
Extends the existing
validate-notebookspre-commit hook (scripts/validate_notebooks.py) with a single-H1 check, scoped todocs/source/notebooks/so dev/scratch notebooks elsewhere are unaffected.The check is robust against the two false-positive sources that were called out in #863:
```and~~~) are skipped — Python comments embedded in markdown code samples (theits_lift_test.ipynbpattern) cannot trigger a violation.Failure messages name each offending cell index and heading text, plus a short remediation hint.
Test coverage in
causalpy/tests/test_notebook_validation.py:```pythonand~~~python) false-positive guards.docs/source/notebooks/ignored).2. New
pr-reviewagent skill.github/skills/pr-review/— orchestratorSKILL.mdplus six focused reference files (workflow.md,what-to-look-for.md,code-patterns.md,docs-patterns.md,posting-comments.md,how-to-extend.md).Captures the review patterns surfaced during the #826 review iteration into a reusable skill: how to fetch PR context, severity-sorted patterns to look for, CausalPy-specific code conventions (
BaseExperiment,_clone(),Literalfor constrained strings, helper-promotion checklist), notebook/docs conventions, comment-drafting templates, and a built-in extension/pruning protocol so the skill stays sharp as patterns get formalised into hooks.Designed to complement (not duplicate) the existing
pr-to-greenandpr-workflowsskills; explicitly defers mechanical checks to hooks/CI.Why these are bundled
The branch was originally scoped to #863, but the skill captures (among other things) "single-H1 enforcement should be a hook, not an agent task" as an explicit pattern. Bundling them keeps the skill's canonical examples accurate from day one. Happy to split into two PRs if a maintainer prefers — they're cleanly separable (no shared files, no shared test surface).
Audit — current docs notebook corpus
(Was 1 prior to #826 landing; the H1 fix in that PR cleared the only outstanding violation.)
Test plan
prek run --all-filespasses locally.$CONDA_EXE run -n CausalPy python -m pytest causalpy/tests/test_notebook_validation.py -vpasses.prekjob picks up the new check via the existingvalidate-notebookshook.#heading in anydocs/source/notebooks/*.ipynbcauses the hook to fail with the expected message.Out of scope
-Won the docs build so Sphinx orphan warnings become errors. Tracked separately from this PR.Related
Made with Cursor