Module check_api_links
Expand description
cargo dev check-api-links — every link in the map resolves to a real page.
§Why this is a separate command
The api-links generator is fail-closed about the code: it refuses to emit
a page path for a symbol whose kind it cannot determine, and
generate-all --mode check fails on drift. Neither of those can tell whether
the paths it emits exist, because knowing that needs two build artefacts
the fast per-push gate does not have — a rustdoc tree and a built site.
The generator’s module docs say its URL rules were “measured against
cargo doc --workspace --all-features --no-deps”. That was true when it was
written and is a claim in a comment thereafter. This command is the same
measurement, run on every build of the docs job
(docs/design/11-documentation-plan.md §11, §1.3.100).
§The three checks
- Forward, Rust. Every
rust:value names a file in the rustdoc tree. - Reverse, Rust. Every item page in the facade’s subtree of that tree is
claimed by some
rust:value, except the entries ofUNCLAIMABLE, each of which carries the reason it cannot be claimed. This is the direction that finds a symbol the guide can never link to. - Anchors, Python and CLI. Every
python:/cli:target’s anchor appears as anid="…"on the page it names.mkdocs build --strictvalidates only the anchors a page actually names, so two dead ones sat in the map until this check found them (§1.3.106).
§Fail-closed on a missing input
A missing rustdoc tree or a missing site/ is an error, never a skipped
check. Four of this milestone’s defects were checks that passed because they
had nothing to look at (§1.3.106 most recently), and a green
check-api-links that ran none of its checks would be the fifth.
§What this command does not check
It never reads docs/api_links.yml. It calls api_links::map and checks the
values the generator would write — so a hand-edited map is invisible here, and
a bite test that corrupts the file produces no failure at all (measured). That
is deliberate, and it is sound only as a pair: generate-all --mode check
is what proves the file equals map()’s output, and this command is what proves
map()’s output resolves. Run one without the other and a hand-edited map slips
through — which is why §11 puts both in the same job.
The alternative, parsing the YAML back, was rejected: it adds a parser to a tool that has deliberately avoided one, and it lets the checker and the generator drift apart in their reading of the same bytes, which is the failure the map exists to prevent one level up.
Structs§
- Cargo
Metadata 🔒 - The one Cargo metadata field needed to find rustdoc output.
- FsPage
Tree 🔒
Constants§
- CHECKER 🔒
- This command’s name, for fail-closed error messages.
- DOC_
COMMAND 🔒 - The command that writes the rustdoc tree, named in the message when it is absent.
- FACADE_
TREE 🔒 - The crate whose rustdoc subtree the reverse check covers.
- ITEM_
PREFIXES 🔒 - Rustdoc’s own file naming, by item kind. A file matching none of these is
machinery —
all.html,sidebar-items.js,static.files/— and is not a symbol’s page. - SITE_
COMMAND 🔒 - The command that writes the site, likewise.
- SITE_
DIR 🔒 - Where the built site is, relative to the repository root.
- UNCLAIMABLE 🔒
- Pages in the facade’s tree that no map key can claim, and why.
Traits§
- Page
Tree 🔒
Functions§
- cargo 🔒
- The cargo that invoked this tool, so a non-default toolchain stays consistent.
- cargo_
metadata_ 🔒failed - Reports a failed metadata command without discarding Cargo’s diagnostics.
- check
- Runs the three checks, reporting every failure rather than the first.
- check_
anchors 🔒 - Every
python:/cli:anchor appears as anid="…"on the page it names. - check_
rust_ 🔒forward - Every
rust:value names a file that exists. - check_
rust_ 🔒reverse - Every item page in the facade’s subtree is claimed by some
rust:value. - check_
rust_ 🔒reverse_ with - collect_
pages_ 🔒with - find_
bytes 🔒 - find_
markup_ 🔒tag_ end - find_
raw_ 🔒text_ end - find_
tag_ 🔒close - html_
identifiers 🔒 - index_
is_ 🔒file - is_
raw_ 🔒text_ element - looks_
like_ 🔒html_ tag - page_
tree_ 🔒error - parse_
cargo_ 🔒metadata - Decodes the metadata shape this checker consumes.
- parse_
html_ 🔒attribute_ value - parse_
html_ 🔒tag - read_
identifiers 🔒 - The
id="…"attributes of one built page. - require_
dir 🔒 - Fails when an input this command reads has not been built.
- rustdoc_
tree 🔒 - The rustdoc output directory, read from cargo rather than assumed.
- skip_
html_ 🔒space - unclassifiable 🔒
- Wraps a message as this command’s fail-closed error.