Implement autofix for the doc sync hook#1727
Merged
nathanjmcdougall merged 3 commits intomainfrom Apr 1, 2026
Merged
Conversation
Replace the check-only check-doc-sync hook with a new fix-doc-sync hook that automatically updates sync blocks in markdown files to match their source files. The hook detects and preserves code block wrappers. The fix-doc-sync hook runs at priority 1 (same group as ruff-format), after the export hooks at priority 0 that generate the source .txt files. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/e21a4040-f951-4ef9-af85-836c1e614916 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/e21a4040-f951-4ef9-af85-836c1e614916 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement autofix for the doc sync hook
Implement autofix for the doc sync hook
Apr 1, 2026
nathanjmcdougall
approved these changes
Apr 1, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
nathanjmcdougall
approved these changes
Apr 1, 2026
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.
Replace the check-only
check-doc-synchook withfix-doc-syncthat auto-updates sync blocks in markdown files to match their source.txtfiles. Runs at priority 1 (same group asruff-format), after the export hooks at priority 0 that generate the source files.hooks/fix-doc-sync.py— New autofix hook. Finds<!-- sync:path -->blocks, reads the referenced source file, and rewrites the block content in-place. Preserves fenced code block wrappers. Returns exit 1 when files are modified (pre-commit convention).hooks/check-doc-sync.py— Removed, superseded by the autofix..pre-commit-config.yaml— Replacedcheck-doc-sync(priority 0) withfix-doc-syncin its ownrepo: localblock at priority 1.check-doc-syncreferences tofix-doc-sync.