Skip to content

Add a docs validator: fragment anchors, broken paths, part-number consistency#423

Open
munzzyy wants to merge 1 commit into
flipperdevices:public-releasefrom
munzzyy:cole/docs-validator
Open

Add a docs validator: fragment anchors, broken paths, part-number consistency#423
munzzyy wants to merge 1 commit into
flipperdevices:public-releasefrom
munzzyy:cole/docs-validator

Conversation

@munzzyy

@munzzyy munzzyy commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This adds tools/validate_docs.py, a standalone script covering three things archbee validate / archbee broken-links (.github/workflows/validate.yml) don't:

  1. Anchor check -- for every internal link with a #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/-2 suffixes for repeated headings).
  2. Path check -- for every internal link and image reference, including Archbee's ::Image[]{src="..."} / :inlineImage[]{src="..."} directives, confirm the target file exists.
  3. Part-number check -- flags part-number "families" (BQ25xxx chargers, BQ28Zxxx fuel gauges, MT7921xxx Wi-Fi chips) that resolve to more than one distinct value across the docs. This one's a warning, not an error, because hardware revs do swap parts sometimes. It surfaces the disagreement for someone to adjudicate instead of assuming either side is wrong.

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-release through 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.png as syntax examples inside ```markdown fences (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):

Warnings (real disagreements, left for a human to resolve, not fixed here):

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 with python -m unittest or directly. All passing. mypy tools/*.py is clean under the same strict config pyproject.toml already has, run the same way test-open-tasks-generator.yml runs it.

This only touches tools/, no workflow files. Run it with python3 tools/validate_docs.py (add --strict to 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.

Signed-off-by: Cole Munz <colemunz@gmail.com>
@NickVolynkin

NickVolynkin commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Hi @munzzyy, thanks for the contribution. I see three separate checks here; let's discuss each one.

Anchor link checker
Great addition to built-in Archbee checks. I've tested it and found a few errors that you've already fixed in #419. Let's add a CI job to run this test. Would you like to do it yourself or let someone else make a contribution?

Image path checker
There are false positive results: the test resolves image paths as relative to the .md file, but it seems that Archbee resolves them as relative to the project root.

ERROR   docs/cpu-software/How-to-install-linux-image.md:14  [path] target 'files/pics/rk3576_maskrom_mode.jpg' does not resolve to an existing file (resolved: docs/cpu-software/files/pics/rk3576_maskrom_mode.jpg)
ERROR   docs/cpu-software/How-to-install-linux-image.md:26  [path] target 'files/pics/rk3576_boot_priority_logic.jpg' does not resolve to an existing file (resolved: docs/cpu-software/files/pics/rk3576_boot_priority_logic.jpg)
ERROR   docs/cpu-software/How-to-install-linux-image.md:32  [path] target 'files/pics/rk3576_boot_mode_config.jpg' does not resolve to an existing file (resolved: docs/cpu-software/files/pics/rk3576_boot_mode_config.jpg)

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 --keys of a single script. We'll need to run these tests separately in CI, so we see precisely what's broken when a test fails.

Part number checker
There is, indeed, an inconsistency. We should certainly fix it, but I don't think we should test it this way. A precise part number/model is almost like a term or a proper name (such as Flipper One). There are dedicated linters for checking terms and proper names, starting with https://vale.sh/.

So, I think it's best to exclude this check from the current PR.


To sum it up, please check the following points:

  • Fix image path resolving
  • Add separate commands or --keys to run anchor and image path checks.
  • Add each check to CI as a separate job step in the validate.yml workflow
  • Remove the model number check.
  • (Optionally) Fix the model number in a separate PR.

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.

2 participants