-
Notifications
You must be signed in to change notification settings - Fork 0
chore(docs): automate documentation synchronization #1442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
76d7372
chore(docs): automate documentation synchronization
BigSimmo 8a22049
docs: record documentation sync review
BigSimmo 0dc4e92
Merge remote-tracking branch 'origin/main' into codex/docs-sync-autom…
BigSimmo 8888c65
docs: update verification gate counts
BigSimmo 4c27b50
docs: normalize review ledger merge
BigSimmo b6d14f5
Merge branch 'main' into codex/docs-sync-automation
BigSimmo 220a1d9
Merge branch 'main' into codex/docs-sync-automation
cursoragent 71aa42e
Merge remote-tracking branch 'origin/main' into codex/review-pr1442
BigSimmo 35fc11a
docs: refresh generated script inventory
BigSimmo a3dff21
docs: record documentation automation review
BigSimmo 672ce52
Merge branch 'main' into codex/docs-sync-automation
cursoragent a40e49b
fix: preserve docs outputs during inventory sync
BigSimmo b58dca1
Merge remote docs automation updates
BigSimmo fba8ab4
Merge Cloud readiness main into docs automation
BigSimmo 577b022
docs: record final documentation automation review
BigSimmo 1c80a93
docs: align verify cheap gate counts
BigSimmo ffa7348
docs: record gate-count follow-up review
BigSimmo e1c514f
Merge current main after issue evidence correction
BigSimmo 14ab262
docs: record issue-evidence sync review
BigSimmo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| #!/bin/sh | ||
| # Keep generated documentation synchronized before relevant commits. The hook | ||
| # writes generated outputs but never stages them: if anything changes, the | ||
| # commit stops so the author can review and stage the exact diff. | ||
| set -eu | ||
|
|
||
| if [ "${SKIP_DOCS_SYNC_HOOK:-}" = "1" ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| staged_files=$(git diff --cached --name-only --diff-filter=ACMRD) | ||
| working_files=$( | ||
| { | ||
| git diff --name-only --diff-filter=ACMRD | ||
| git ls-files --others --exclude-standard | ||
| } | sort -u | ||
| ) | ||
|
|
||
| matches_staged() { | ||
| printf '%s\n' "$staged_files" | grep -Eq "$1" | ||
| } | ||
|
|
||
| sync_sitemap=0 | ||
| sync_inventory=0 | ||
| check_module_map=0 | ||
|
|
||
| if matches_staged '^(src/app/|mockups/|src/lib/(app-modes|document-flow-routes|differentials|dsm|formulation|forms|services|specifiers|therapies)\.ts$|scripts/generate-site-map\.ts$|docs/site-map\.md$)'; then | ||
| sync_sitemap=1 | ||
| fi | ||
| if matches_staged '^(scripts/|package\.json$|docs/scripts-index\.md$)'; then | ||
| sync_inventory=1 | ||
| fi | ||
| if matches_staged '^(src/app/|src/lib/|supabase/schema\.sql$|docs/codebase-index\.md$)'; then | ||
| check_module_map=1 | ||
| fi | ||
| if [ "$sync_sitemap" = "0" ] && [ "$sync_inventory" = "0" ] && [ "$check_module_map" = "0" ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Generators read the working tree. Refuse to combine staged inputs with other | ||
| # unstaged inputs that could make the generated docs describe the wrong commit. | ||
| mixed_inputs="" | ||
| if [ "$sync_sitemap" = "1" ]; then | ||
| mixed_inputs=$(printf '%s\n' "$working_files" | grep -E '^(src/app/|mockups/|src/lib/(app-modes|document-flow-routes|differentials|dsm|formulation|forms|services|specifiers|therapies)\.ts$|scripts/generate-site-map\.ts$)' || true) | ||
| fi | ||
| if [ "$sync_inventory" = "1" ]; then | ||
| inventory_inputs=$(printf '%s\n' "$working_files" | grep -E '^(scripts/|package\.json$)' || true) | ||
| mixed_inputs=$(printf '%s\n%s\n' "$mixed_inputs" "$inventory_inputs" | sed '/^$/d' | sort -u) | ||
| fi | ||
| if [ "$check_module_map" = "1" ]; then | ||
| module_inputs=$(printf '%s\n' "$working_files" | grep -E '^(src/app/|src/lib/|supabase/schema\.sql$)' || true) | ||
| mixed_inputs=$(printf '%s\n%s\n' "$mixed_inputs" "$module_inputs" | sed '/^$/d' | sort -u) | ||
| fi | ||
| if [ -n "$mixed_inputs" ]; then | ||
| echo "[pre-commit] Documentation inputs have unstaged or untracked changes:" >&2 | ||
| printf '%s\n' "$mixed_inputs" >&2 | ||
| echo "[pre-commit] Stage or separate these inputs before regenerating commit documentation." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| docs_to_check="" | ||
| if [ "$sync_sitemap" = "1" ]; then | ||
| docs_to_check="$docs_to_check docs/site-map.md" | ||
| fi | ||
| if [ "$sync_inventory" = "1" ]; then | ||
| docs_to_check="$docs_to_check docs/scripts-index.md" | ||
| fi | ||
| if [ "$check_module_map" = "1" ]; then | ||
| docs_to_check="$docs_to_check docs/codebase-index.md" | ||
| fi | ||
|
|
||
| # Generators rewrite whole files. Refuse before running them when a selected | ||
| # output has an unstaged edit, otherwise regeneration can erase local work and | ||
| # leave the hook looking clean afterward. | ||
| dirty_generated_docs=$(git diff --name-only -- $docs_to_check) | ||
| if [ -n "$dirty_generated_docs" ]; then | ||
| echo "[pre-commit] Generated documentation has unstaged changes:" >&2 | ||
| printf '%s\n' "$dirty_generated_docs" >&2 | ||
| echo "[pre-commit] Stage or separate these outputs before regeneration." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v npm >/dev/null 2>&1; then | ||
| echo "[pre-commit] npm is required for documentation synchronization." >&2 | ||
| echo "[pre-commit] Install the repository toolchain, or bypass once with SKIP_DOCS_SYNC_HOOK=1." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| repo_root=$(git rev-parse --show-toplevel) | ||
| cd "$repo_root" | ||
|
|
||
| echo "[pre-commit] Synchronizing generated documentation..." | ||
| if [ "$sync_sitemap" = "1" ]; then | ||
| npm run sitemap:update | ||
| fi | ||
| if [ "$sync_inventory" = "1" ]; then | ||
| node scripts/update-docs-inventory.mjs | ||
| npm run docs:check-inventory | ||
| fi | ||
| if [ "$check_module_map" = "1" ]; then | ||
| npm run docs:check-index | ||
| fi | ||
|
|
||
| unstaged_docs=$(git diff --name-only -- $docs_to_check) | ||
| if [ -n "$unstaged_docs" ]; then | ||
| echo "[pre-commit] Documentation changed or remains unstaged:" >&2 | ||
| printf '%s\n' "$unstaged_docs" >&2 | ||
| echo "[pre-commit] Review and stage these files, then commit again." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "[pre-commit] Documentation is synchronized." | ||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.