Enforce README syncing with docs dir via Jinja2 template and hook#1730
Merged
nathanjmcdougall merged 5 commits intomainfrom Apr 1, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/3d47e812-7793-44fb-8c22-6c925345f5ff Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/3d47e812-7793-44fb-8c22-6c925345f5ff Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add README syncing with docs directory via hook
Enforce README syncing with docs dir via Jinja2 template and hook
Apr 1, 2026
nathanjmcdougall
requested changes
Apr 1, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/181a66fb-f111-47de-8f55-e47b6593475b Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
nathanjmcdougall
approved these changes
Apr 1, 2026
Collaborator
|
We should deprecate the test_assemble_readme_from_docs test, which basically encodes the logic we want out of the hook. Then, we can configure the GitHub actions workflows to skip any changes to .md files, anywhere, and all changes in the docs dir. The only exception would be the static checks workflow - that would still run. |
… to CI Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/8049bb38-5414-4c85-975a-effbbe1cfe80 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Contributor
Author
Done in da1a1a1:
|
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.
README.md is manually assembled from several
docs/files with transformations (header demotion, link absolutization, TIP callout wrapping). This was only validated by a test, not enforced at commit time.Adds a Jinja2 template + pre-commit hook that auto-generates
README.mdfrom doc sources, replacing the manual sync workflow.docs/README.md.jinja— Template with{{ include_doc(...) }}calls that pull in content fromdocs/with per-include transformationshooks/fix-readme.py— Fixer hook (exit 1 on modification, following existing export hook pattern)._include_doc()supportsskip_lines,demote_headers,replacementsdict, andtip_textcallout wrapping.pre-commit-config.yaml— Registersfix-readmeat priority 1 (after markdownlint/prettier process doc files at priority 0)tests/docs/test_readme.py— Thetest_assemble_readme_from_docstest is now redundant since the hook enforces the same invariant at commit time.github/workflows/ci.yml— Addeddocs/**and**/*.mdtopaths-ignore(for bothpushandpull_request), matching the patterns already used by codecov, codspeed, codeql, and zizmor workflows. Thestatic-checks.ymlworkflow intentionally has nopaths-ignoreand continues to run on all changes.Template usage in
docs/README.md.jinja:{{ include_doc("docs/index.md", skip_lines=2, demote_headers=false) }} {{ include_doc("docs/cli/overview.md", replacements={"](reference.md#": "](https://usethis.readthedocs.io/en/stable/cli/reference#"}) }} {{ include_doc("docs/about/similar-projects.md", replacements={...}, tip_text="You can still use usethis") }}Jinja2 is already a dev dependency.