Skip to content

fix: apply exclude_docs of pulled docs - #246

Merged
uniqueg merged 4 commits into
devfrom
fix/pulled-docs-exclude
Nov 6, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/pulled-docs-exclude

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

The docs hook pulls the docs/ of tesk-api and tesk-core into TESK's site. Their docs/requirements.txt (for their own Read the Docs builds) was published (/tesk-api/requirements.txt, /tesk-core/requirements.txt): both list it in exclude_docs of their mkdocs.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-level templates/) and exclude_docs exclude it, draft_docs makes it a draft, not_in_nav keeps 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 (no nav in the pulled mkdocs.yml) lists only included pages. Invalid settings fail with the file named.

pathspec (which MkDocs uses for these patterns) is now declared in the docs group; uv.lock updated. docs/development.md ("Docs of tesk-api and tesk-core") documents the rules, and that !ENV and INHERIT aren'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 in on_files, defaults with missing/empty settings, invalid settings, the fallback nav, and a real strict mkdocs build with 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 --strict with the pinned tesk-api and tesk-core docs: passes; no requirements.txt in the site (two before).
  • ruff 0.17.3 (check, format), mypy, uv lock --check: clean.

Review

Full review: adversarial-reviewer and quality-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_nav were ignored; duplicated config loading; dependency wording; test gaps.

Declined review findings

  • exclude_docs: !ENV VAR (scalar form) is read as the pattern VAR instead of failing: tags are ignored when reading the pulled mkdocs.yml (as for its nav), the docs say !ENV isn't supported in these settings, and pulled commits are pinned and reviewed before pinning. Neither pulled repository uses it.
  • Compare DEFAULT_EXCLUDE with MkDocs' private _default_exclude in 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:

  • Apply each pulled repository's MkDocs exclusion, draft, and navigation settings so excluded documentation files are not published and strict builds do not warn about valid links or nav entries.

Enhancements:

  • Preserve pulled files with MkDocs-compatible inclusion levels and filter excluded pages from fallback navigation.
  • Validate pulled documentation settings and document the supported inclusion rules.

Build:

  • Add pathspec as a documentation dependency and update the lockfile.

Documentation:

  • Document how pulled repositories' MkDocs file inclusion settings are applied.

Tests:

  • Add coverage for inclusion levels, defaults, invalid settings, fallback navigation, and strict builds involving excluded pages.

uniqueg and others added 3 commits November 6, 2026 17:26
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Implementation

Load 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.

  • docs/hooks.py L272-358, L368-383, L500-509 (+3 small edits)

Configuration

Declare pathspec as a direct documentation dependency for matching the pulled repositories’ MkDocs patterns.

  • pyproject.toml L35-36

Update the lockfile for the new documentation dependency.

  • uv.lock L983-1021 (4 small edits)

Documentation

Document the supported inclusion settings and default exclusions for pulled documentation, including the requirement to list non-site files in exclude_docs.

  • docs/development.md L100-102, L118-124

Update the hook documentation to explain how each pulled repository’s inclusion settings apply.

  • docs/hooks.py L12-15

Tests

Test fallback navigation, file inclusion levels, defaults, invalid settings, and strict builds with links and nav entries to excluded files.

  • tests/test_hooks.py L15-19, L277-288, L386-502

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a73a987) to head (27d9fe7).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 6, 2026 16:30

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/hooks.py Resolved
Comment thread docs/hooks.py Resolved
@uniqueg
uniqueg merged commit 27a6945 into dev Nov 6, 2026
28 checks passed
@uniqueg
uniqueg deleted the fix/pulled-docs-exclude branch November 6, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: pulled docs publish their requirements.txt

1 participant