Repository navigation
fix: apply exclude_docs of pulled docs - #246
Conversation
MkDocs applies only the site's exclude_docs, so the requirements.txt of tesk-api and tesk-core, which their own sites exclude, was published in TESK's site. The hook now leaves out what the pulled repository's exclude_docs and MkDocs' default exclusions match. pathspec, which MkDocs uses for this, is now a direct docs dependency. Closes #244 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without a nav in the pulled mkdocs.yml, the section listed all pages, including excluded ones, which the strict build would reject. Read the pulled mkdocs.yml in one place, and test empty exclude_docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Dropping excluded files turned nav entries and links to them into warnings, which fail the strict build, where the pulled site gives only infos. Add pulled files with the inclusion level their own site gives them, as MkDocs does: exclude_docs (with MkDocs' defaults), draft_docs and not_in_nav. Invalid patterns fail with the file named. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideImplementationLoad each pulled repository’s MkDocs settings and assign its files the matching inclusion levels, keeping excluded files available so links and nav entries do not trigger strict-build warnings.
ConfigurationDeclare pathspec as a direct documentation dependency for matching the pulled repositories’ MkDocs patterns.
Update the lockfile for the new documentation dependency.
DocumentationDocument the supported inclusion settings and default exclusions for pulled documentation, including the requirement to list non-site files in
Update the hook documentation to explain how each pulled repository’s inclusion settings apply.
TestsTest fallback navigation, file inclusion levels, defaults, invalid settings, and strict builds with links and nav entries to excluded files.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #246 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 199 229 +30
=========================================
+ Hits 199 229 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/hooks.py" line_range="286" />
<code_context>
+ if not config.is_file():
+ return {}
+ data = yaml.load(config.read_text(encoding="utf-8"), Loader=_Loader) # noqa: S506
+ return data if isinstance(data, dict) else {}
+
+
</code_context>
<issue_to_address>
**Excluded files leak from invalid config**
When a pulled `mkdocs.yml` has a non-mapping document or an explicit null exclusion setting, such as `exclude_docs:`, `load_config` converts a non-mapping document to `{}`, and `_patterns` treats an explicit null setting as absent, so the pulled repository’s exclusions are skipped and files intended to be excluded can be published.
Reject non-mapping configs and explicitly present null exclusion settings with an error naming the pulled `mkdocs.yml`, while retaining defaults when the file or setting is absent.
Also at `docs/hooks.py:305`.
</issue_to_address>
### Comment 2
<location path="docs/hooks.py" line_range="304" />
<code_context>
+ PluginError: If the setting is not a string of valid patterns, as
+ MkDocs requires.
+ """
+ value = config.get(key)
+ if value is not None and not isinstance(value, str):
+ raise PluginError(
</code_context>
<issue_to_address>
**Scalar !ENV exclusions silently misapply**
When a pulled `mkdocs.yml` uses scalar `!ENV` syntax for one of these settings, `_ignore_tags` turns `exclude_docs: !ENV EXCLUDE_DOCS` into the plain string `EXCLUDE_DOCS`, which `_patterns` accepts as a literal pattern; the pulled site therefore publishes files its own environment-expanded configuration excludes.
Detect tagged setting values and raise a `PluginError` naming the configuration file instead of treating the tag's payload as a literal pattern.
</issue_to_address>Linked issues
#244 fix: pulled docs publish their requirements.txt · 3 of 4 met · 1 to check by hand
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Apply pulled repositories’ exclude_docs and MkDocs’ default exclusions. |
✅ Met | The hook assigns matched files EXCLUDED, including hidden files and a top-level templates/; MkDocs therefore does not publish them. |
| 2 | Test the exclusions. | ✅ Met | Tests cover exclude_docs, default exclusions, and a strict build confirming an excluded requirements.txt is not published. |
| 3 | Document the behavior in “Docs of tesk-api and tesk-core” in docs/development.md. |
✅ Met | The section documents the supported patterns and default exclusions. |
| 4 | The strict docs build publishes no requirements.txt of tesk-api or tesk-core. |
👀 Check by hand (runtime) | Run the strict docs build against the pinned tesk-api and tesk-core docs and confirm neither requirements.txt is published. |
Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: docs/hooks.py:286, docs/hooks.py:304
Summary
The docs hook pulls the
docs/of tesk-api and tesk-core into TESK's site. Theirdocs/requirements.txt(for their own Read the Docs builds) was published (/tesk-api/requirements.txt,/tesk-core/requirements.txt): both list it inexclude_docsof theirmkdocs.yml, but MkDocs applies only TESK's settings.The hook now gives each pulled file the inclusion level its own site gives it, as MkDocs does (
set_exclusions): MkDocs' default exclusions (hidden files, a top-leveltemplates/) andexclude_docsexclude it,draft_docsmakes it a draft,not_in_navkeeps it out of nav warnings. Excluded files stay in the file list as excluded (rather than being dropped), so nav entries and links to them are INFO, not warnings that would fail the strict build, as in the pulled repository's own build. The fallback nav (nonavin the pulledmkdocs.yml) lists only included pages. Invalid settings fail with the file named.pathspec(which MkDocs uses for these patterns) is now declared in thedocsgroup;uv.lockupdated.docs/development.md("Docs of tesk-api and tesk-core") documents the rules, and that!ENVandINHERITaren't supported in these settings.Closes #244
Verification
REQUIRE_HELM=1 coverage run -m pytest(helm 3.22.1): 78 passed; coverage 100%. New tests: inclusion levels inon_files, defaults with missing/empty settings, invalid settings, the fallback nav, and a real strictmkdocs buildwith a nav entry and a link to an excluded pulled page (fails on the previous version of the fix with "Aborted with 2 warnings in strict mode!").mkdocs build --strictwith the pinned tesk-api and tesk-core docs: passes; norequirements.txtin the site (two before).uv lock --check: clean.Review
Full review:
adversarial-reviewerandquality-reviewer, two rounds. Fixed: dropping excluded files broke strict builds on nav entries/links to them; the fallback nav listed excluded pages; raw pathspec errors;draft_docs/not_in_navwere ignored; duplicated config loading; dependency wording; test gaps.Declined review findings
exclude_docs: !ENV VAR(scalar form) is read as the patternVARinstead of failing: tags are ignored when reading the pulledmkdocs.yml(as for itsnav), the docs say!ENVisn't supported in these settings, and pulled commits are pinned and reviewed before pinning. Neither pulled repository uses it.DEFAULT_EXCLUDEwith MkDocs' private_default_excludein a test: it's private API; MkDocs is bounded<2, and the strict-build test covers the behaviour.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Apply the pulled documentation site's MkDocs file inclusion rules when integrating external documentation.
Bug Fixes:
Enhancements:
Build:
Documentation:
Tests: