Repository navigation
Strict mode: ZDOCS_STRICT reports every document's warnings in the doc-check gate - #36
Open
tobiaskaestner wants to merge 1 commit into
Open
tobiaskaestner wants to merge 1 commit into
tobiaskaestner wants to merge 1 commit into
Conversation
By default a dangling need link, a sphinx-needs schema violation or an unresolved reference does not fail the build. With -W in ZDOCS_SPHINXOPTS_EXTRA it does, but the build tool stops at the first failed document, and with a dangling link imported from a peer that is often an innocent one: the document with the broken link never reports. The cache option ZDOCS_STRICT (default OFF) makes the doc-check gate (add_doc_check: the POST_BUILD step of all-docs and the doc-check target) run doccheck.py --strict. That reads the stage-2 warning file of every Sphinx build of the set (<build>/<doc>/build/<builder>.log, written by sphinx-build -w) and reports each warning and error as "<doc> (<builder>): <message>", with the build directory cut from the paths. Sphinx runs without -W, so every document is built whatever the build tool, and the gate names every document with a warning. Stage-1 files are not read: stage 2 parses every document again. The findings go through doc_check_accepted: like the others. A strict check that finds no warning file fails, and ZDOCS_STRICT without an add_doc_check() call is a configure error. ADR 0015 records the decision; the consumer contract and the CLI reference describe the option and the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tobias Kaestner <tobias.kaestner@inovex.de>
This branch has not been deployed
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.
Closes #29
Based on
main, independent of #35 (sphinx-needs 9.2): unit suites pass with 8.3 (561) as well. ADR number: this adds ADR 0015. The PRs for #25 and #26 add 0016 and 0017. Each of them adds one line after0014indecisions/index.rst, so the second and third to merge get a trivial conflict there. I can rebase on request.What changed
A cache option
ZDOCS_STRICT(defaultOFF). When it is on:-W. A warning does not fail its target, so every document is built, whatever the build tool and its options (no-k 0needed).add_doc_checkrunsdoccheck.py --strictin the gate (thePOST_BUILDstep ofall-docsand thedoc-checktarget). New check D reads the stage-2 warning file thatsphinx-build -wwrites for every Sphinx build of the set (<build>/<doc>/build/<builder>.log). It reports each warning and error as<doc> (<builder>): <message>, so every document with a warning is named. The build directory is cut from the messages, so the text is the same on every host and works withdoc_check_accepted:.xref.logis not read. Stage 2 parses every document again, and stage 1 has the warnings thatxref_builderexplains. This matches the documentation guidelines: "doc-check plus a clean stage-two build log, notsphinx-build -W". It also means thatneedflow's "only supported for HTML" from the stage-1 builder (needflowwarns in the stage-1xrefbuilder and fails strict builds #30) does not fail a strict build.ZDOCS_STRICT=ONwithout anadd_doc_check()call is a configure error (cmake_language(DEFER)).ZDOCS_STRICT, plus a hint atZDOCS_SPHINXOPTS_EXTRA), the CLI reference (check D), and theadd_doc_checkreference.Why
With
-W, ninja stops at the first failed document. With a dangling link imported from a peer, that is often an innocent document, and the culprit never reports.-k 0cannot be set from CMake and differs per build tool.How tested
test_doccheck_strict.py(5 tests) uses realsphinx-build -wruns (a dangling need link, an undefined label, a clean document and an external one). It covers pass without--strict, every affected document named, no host path, acceptance by text, and that an empty check fails. Full suites: 561 passed (sphinx-needs 8.3, CI pins) and 560 + the known 8.3 control (9.2).zdocs-tests): same result asmain(238 passed, the same 11 environment-caused failures, 20 skipped; details in sphinx-needs 9.2; unique prefixes; no group with a document's target name #35). The suite does not turn strict mode on.-DZDOCS_STRICT=ON:doccheck: OK (deploy tree, strict: 2 Sphinx warning file(s) clean).-DZDOCS_SPHINXOPTS_EXTRA="-W;--keep-going"withZDOCS_STRICT ON, and dropped-- -k 0from its build command:needs.undeclared_for_type) plus a dangling link (needs.link_outgoing) in the upstream requirements document: the build fails once at the gate, with 6 findings that name all 5 documents. The culprit is listed with both of its own warnings, and the 4 importers withneeds.external_link_outgoing;ZDOCS_STRICT=ONwithoutadd_doc_check(): configure fails with the message.Open questions
-W. The issue proposed-W --keep-goingplus-k 0. I put the failure in the gate instead, because CMake cannot make the build tool keep going. Consequence: a single document target (cmake --build . --target se-req-html) does not fail on its warnings in strict mode. Onlyall-docs/doc-checkfail, and Sphinx still prints the warnings. Is that acceptable, or should strict mode also add-W(and accept the stop-at-first-failure behaviour for direct target builds)?-W, the gate sees only the warnings of the documents the last build read again. An incremental build that reads nothing again reports nothing, so CI should build from scratch. This is documented.schema_violations.json(the violations are already in the warning file), and turning strict mode on for zdocs' owndoc/set. It builds clean in strict mode, so this could be a one-line follow-up.needs.external_link_outgoingin strict mode would leave only the culprit, but it would hide real problems in a set where the defining document is not built. Per-document needs imports instead of all-to-all #26 (imports:) reduces the repetition instead.🤖 Generated with Claude Code