|
| 1 | +--- |
| 2 | +description: Show which documentation files may need updating based on changed source files |
| 3 | +argument-hint: "[file1.py file2.py ...]" |
| 4 | +--- |
| 5 | + |
| 6 | +# Documentation Impact Report |
| 7 | + |
| 8 | +Identify which documentation files may need updating when source files in `diff_diff/` change. |
| 9 | +Uses the dependency map at `docs/doc-deps.yaml`. |
| 10 | + |
| 11 | +## Arguments |
| 12 | + |
| 13 | +`$ARGUMENTS` is an optional space-separated list of source file paths (e.g., `diff_diff/staggered.py`). |
| 14 | +If empty, auto-detect changed files from git. |
| 15 | + |
| 16 | +## Instructions |
| 17 | + |
| 18 | +### 1. Load Dependency Map |
| 19 | + |
| 20 | +Read `docs/doc-deps.yaml` using the Read tool. |
| 21 | + |
| 22 | +If the file does not exist or cannot be parsed, display: |
| 23 | +``` |
| 24 | +Error: docs/doc-deps.yaml not found or malformed. Cannot generate impact report. |
| 25 | +``` |
| 26 | +And stop. |
| 27 | + |
| 28 | +### 2. Identify Changed Source Files |
| 29 | + |
| 30 | +**If `$ARGUMENTS` is non-empty**: Use those file paths directly as the changed files list. |
| 31 | + |
| 32 | +**If `$ARGUMENTS` is empty**: Auto-detect from git: |
| 33 | + |
| 34 | +```bash |
| 35 | +# Unstaged changes |
| 36 | +git diff --name-only HEAD 2>/dev/null || true |
| 37 | +# Staged changes |
| 38 | +git diff --cached --name-only 2>/dev/null || true |
| 39 | +# Untracked files |
| 40 | +git ls-files --others --exclude-standard 2>/dev/null || true |
| 41 | +``` |
| 42 | + |
| 43 | +Filter results to only files matching `diff_diff/**/*.py`. Deduplicate. |
| 44 | + |
| 45 | +If no source files found, display: |
| 46 | +``` |
| 47 | +No changed source files in diff_diff/ detected. Nothing to report. |
| 48 | +``` |
| 49 | +And stop. |
| 50 | + |
| 51 | +### 3. Resolve Group Membership |
| 52 | + |
| 53 | +For each changed file, check if it appears in any `groups:` list in the YAML. |
| 54 | +If it does, resolve it to the **first entry** in that group (the primary module). |
| 55 | +This is the key used for doc lookup in the `sources:` section. |
| 56 | + |
| 57 | +Example: if `diff_diff/staggered_bootstrap.py` changed, it resolves to `diff_diff/staggered.py` |
| 58 | +because it is in the `staggered` group. |
| 59 | + |
| 60 | +### 4. Look Up Impacted Docs |
| 61 | + |
| 62 | +For each resolved source entry in the `sources:` section: |
| 63 | +1. Get the `drift_risk` level |
| 64 | +2. Get the list of `docs` entries (path, type, section, note) |
| 65 | + |
| 66 | +Collect all impacted docs across all changed files. Deduplicate by path, but merge |
| 67 | +section hints from different sources (e.g., REGISTRY.md may be referenced by both |
| 68 | +staggered.py and survey.py with different section hints). |
| 69 | + |
| 70 | +### 5. Validate Doc Paths |
| 71 | + |
| 72 | +For each unique doc `path` in the results, verify the file exists on disk using the |
| 73 | +Read tool (or Glob). If a path does not exist, flag it: |
| 74 | +``` |
| 75 | +[STALE] docs/doc-deps.yaml references non-existent file: <path> |
| 76 | +``` |
| 77 | + |
| 78 | +### 6. Display Report |
| 79 | + |
| 80 | +Group results by drift risk level (HIGH first, then MEDIUM, then LOW). |
| 81 | +Within each group, show the type label and path, with section hints where available. |
| 82 | + |
| 83 | +**Output format:** |
| 84 | + |
| 85 | +``` |
| 86 | +=== Documentation Impact Report === |
| 87 | +Changed: <comma-separated list of changed source files> |
| 88 | +
|
| 89 | +HIGH DRIFT RISK: |
| 90 | + [methodology] docs/methodology/REGISTRY.md -- <section hints> |
| 91 | + [roadmap] docs/survey-roadmap.md |
| 92 | +
|
| 93 | +MEDIUM DRIFT RISK: |
| 94 | + [user_guide] README.md -- <section hints> |
| 95 | + [tutorial] docs/tutorials/02_staggered_did.ipynb |
| 96 | + [performance] docs/benchmarks.rst |
| 97 | +
|
| 98 | +LOW DRIFT RISK: |
| 99 | + [api_reference] docs/api/staggered.rst |
| 100 | +
|
| 101 | +No map entry: <files not found in sources or groups, or "(none)"> |
| 102 | +Stale references: <invalid paths, or "(none)"> |
| 103 | +Always update: CHANGELOG.md |
| 104 | +``` |
| 105 | + |
| 106 | +### 7. Flag Missing Entries |
| 107 | + |
| 108 | +List any changed source files that had no entry in the `sources:` section and were not |
| 109 | +members of any group: |
| 110 | +``` |
| 111 | +No map entry: diff_diff/new_module.py (consider adding to docs/doc-deps.yaml) |
| 112 | +``` |
| 113 | + |
| 114 | +## Examples |
| 115 | + |
| 116 | +```bash |
| 117 | +# Auto-detect from git status |
| 118 | +/docs-impact |
| 119 | + |
| 120 | +# Check specific files |
| 121 | +/docs-impact diff_diff/staggered.py diff_diff/survey.py |
| 122 | +``` |
0 commit comments