Add a docs validator: fragment anchors, broken paths, part-number consistency#423
Add a docs validator: fragment anchors, broken paths, part-number consistency#423munzzyy wants to merge 1 commit into
Conversation
Signed-off-by: Cole Munz <colemunz@gmail.com>
|
Hi @munzzyy, thanks for the contribution. I see three separate checks here; let's discuss each one. Anchor link checker Image path checker For example
I've checked if Archbee can detect an actually broken image path, and it cannot. So, the test is actually useful, but needs to be fixed first. Please also split the anchor link and image path checkers into separate scripts or different Part number checker So, I think it's best to exclude this check from the current PR. To sum it up, please check the following points:
|
This adds
tools/validate_docs.py, a standalone script covering three thingsarchbee validate/archbee broken-links(.github/workflows/validate.yml) don't:#fragment, resolve the target page and confirm the fragment actually matches one of its headings (computed the same way GitHub computes heading anchors: lowercase, strip punctuation, spaces to hyphens,-1/-2suffixes for repeated headings).::Image[]{src="..."}/:inlineImage[]{src="..."}directives, confirm the target file exists.Archbee's checker resolves that a link's target file exists, but it doesn't parse the target's headings to confirm the fragment is real, and it has no concept of a part number at all. That's a real gap: #419 fixes 4 broken-anchor/path bugs that have been sitting on
public-releasethrough every CI run, and #420/#422 cover a part-number mismatch (BQ25792 vs BQ25798, BQ28Z610 vs BQ28Z620) that no automated check would have caught either.Fenced code blocks are skipped by every check, since the contribution guide pages use placeholder paths like
your-image.pngas syntax examples inside```markdownfences (About-Docs.md,About-Hardware.md) -- those aren't real broken links and shouldn't be flagged.What it finds on current
public-release: 8 errors, 16 warnings, all triaged by hand, zero false positives.Errors (all genuinely broken):
#contributing-a-third-party-modulelinks indev-log/4.mdanddev-log/5.md-- fixed by Fix broken section anchors and an image path, add missing eSIM mention #419./.#comment-on-an-open-tasklink onAbout-Testing.md-- fixed by Fix broken section anchors and an image path, add missing eSIM mention #419.Video-decoding.md-- fixed by Fix broken section anchors and an image path, add missing eSIM mention #419.cpu-software/How-to-install-linux-image.mdhas three::Image[]{src="files/pics/..."}directives all missing the leading/. Worth noting these each carry agithubPath="docs/files/pics/..."attribute with the correct full path right next to the brokensrc-- looks like whatever generated these directives got the two attributes out of sync. I didn't fix these here since this PR is about the checker, not the docs, but they're real and reproducible on HEAD.Warnings (real disagreements, left for a human to resolve, not fixed here):
Tech-Specs.md) vs BQ25798 (Heatsink.md) and BQ28Z610 (Tech-Specs.md) vs BQ28Z620 (Power-subsystem.md) -- same mismatch as Battery, charger, and fuel gauge specs differ between Tech-Specs and the power/mechanics pages #420, being resolved in Fix charger and fuel gauge part numbers to match the shipped hardware #422.Tech-Specs.md,WiFi-Bluetooth.md,WiFi.md,WiFi-DBDC.md, anddev-log/4.md(12 occurrences). I looked into this one previously and couldn't find a public source that resolves which suffix is correct, so it's flagged rather than fixed -- exactly the case this check is meant to surface for a human with the datasheet, not to auto-resolve.Won't catch: the missing "eSIM" mention on
Tech-Specs.md's interfaces list, also fixed in #419. That's a plain content omission, not a link or part-number mismatch, and this kind of structural check has no way to see it.Testing:
tools/test_validate_docs.py, unittest, 35 tests covering slug computation (punctuation, emoji, duplicate headings, markdown/directive syntax inside headings), fragment resolution, the Archbee image directive parsing, code-fence skipping, and part-family divergence detection. Runs withpython -m unittestor directly. All passing.mypy tools/*.pyis clean under the same strict configpyproject.tomlalready has, run the same waytest-open-tasks-generator.ymlruns it.This only touches
tools/, no workflow files. Run it withpython3 tools/validate_docs.py(add--strictto also fail on the part-number warnings). Happy to add a small CI job wired the same way as the existing "Test Open Tasks generator" workflow if that's wanted, but figured the workflow wiring itself should be your call.