FIX: Sync docs TOC with generated API pages + fail-fast TOC validation#1793
Open
romanlutz wants to merge 2 commits into
Open
FIX: Sync docs TOC with generated API pages + fail-fast TOC validation#1793romanlutz wants to merge 2 commits into
romanlutz wants to merge 2 commits into
Conversation
The Read the Docs build was failing because doc/myst.yml referenced api/pyrit_common_cli_helpers.md, which is never produced by build_scripts/gen_api_md.py. The generator only emits per-submodule pages when the parent module is a pure aggregate (only submodules, no direct API). pyrit.common has its own public API, so its cli_helpers submodule is not expanded into a separate page. Also adds the missing api/pyrit_output.md entry, which is generated by the script but was not listed in the TOC. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Read the Docs build for microsoft#1753 quietly failed because jupyter-book emits "Table of contents entry does not exist" as warnings rather than errors, and --strict does not promote them. The CI deploy-book job and every per-PR check passed; only RTD surfaced the failure. Move that check upstream into the generator itself: - validate_docs.py now auto-detects whether doc/api/ exists. Pre-commit (before any docs build) keeps skipping api/* like today; after gen_api_md.py runs, api/* entries are validated like any other TOC file and orphan detection covers generated pages too. - gen_api_md.py invokes validate_docs.main() after writing the pages and propagates a non-zero exit code, so Makefile / CI / RTD all fail fast when doc/myst.yml drifts from the generator output in either direction (stale entry or missing entry). - Extended test_validate_docs.py to cover the new conditional behavior in both directions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
The Read the Docs build was failing (
Success: False) becausedoc/myst.ymlreferencedapi/pyrit_common_cli_helpers.md, which is never produced bybuild_scripts/gen_api_md.py. The generator only emits per-submodule pages when the parent module is a pure aggregate (only submodules, no direct API).pyrit.commonhas its own public API, so itscli_helperssubmodule is not expanded into a separate page, causing the build log to emit hundreds of⛔️ myst.yml Table of contents entry does not exist: api/pyrit_common_cli_helpers.mdlines.Two changes in this PR
1. Fix the immediate build break (
doc/myst.yml)api/pyrit_common_cli_helpers.md(the helper functions inpyrit/common/cli_helpers.pyare internal CLI plumbing and don't need their own API page).api/pyrit_output.mdentry, which is generated by the script but was not listed in the TOC.2. Prevent this class of regression
The reason this slipped past CI is that
jupyter-book build --strictdoes not treat⛔️ Table of contents entry does not existas an error. PR #1753'sdeploy-bookcheck passed (exit 0); every per-PR check was green. Only Read the Docs surfaced the failure because its build harness flagged the lack of generated output downstream.This PR moves the check upstream into the generator itself:
build_scripts/validate_docs.pynow auto-detects whetherdoc/api/exists. Pre-commit (before any docs build) keeps skippingapi/*like today; aftergen_api_md.pyruns,api/*entries are validated like any other TOC file, and orphan detection covers generated pages too.build_scripts/gen_api_md.pyinvokesvalidate_docs.main()after writing the pages and propagates its non-zero exit code, so the Makefile, CI, and RTD all fail fast whendoc/myst.ymldrifts from the generator output in either direction (stale entry or missing entry).tests/unit/build_scripts/test_validate_docs.pyis extended to cover the new conditional behavior in both directions.Verification
Verified locally with both directions of mismatch:
Stale TOC entry (added a bogus
api/pyrit_nonexistent.mdto the TOC):Missing TOC entry (removed
api/pyrit_output.mdfrom the TOC):Happy path (good TOC):
[OK] All documentation validations passed!→ exit 0.Pre-commit invocation (no
doc/api/directory): still skipsapi/*entries — unchanged from today.Full unit test suite:
73 passed in 1.16s.