Skip to content

test(scripts): check relative links and anchors in the docs (#228) - #251

Merged
juancguerrerodev merged 10 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/docs-links-228
Dec 6, 2026
Merged

juancguerrerodev merged 10 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/docs-links-228

Conversation

@saurabhbhoir456

@saurabhbhoir456 saurabhbhoir456 commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #228

The docs link to each other a lot, and every relative link pointed at a file that exists and every #anchor matched a
heading, but nothing checked it. A broken link in a contributor doc is the first thing a new contributor trips on.

What this PR does

  • Adds scripts/docs-links.mjs with two pure functions: linksIn(markdown), the targets of the inline links
    [text](target) in a Markdown text, skipping fenced code blocks and inline code; and slug(heading), the GitHub
    anchor for a heading (lower case, punctuation dropped, spaces as -, accents kept).
  • Adds scripts/docs-links.test.mjs (node:test, like scripts/check-privacy.test.mjs): unit tests of both helpers on
    made-up Markdown (a link in a code block or inline code is skipped, https: and mailto: links are returned for the
    caller to skip, slug("How to propose work") is how-to-propose-work, slug("Qué hace") is qué-hace), plus a
    walk over every .md file tracked by git (git ls-files "*.md") checking that each relative link's file exists and,
    when there is an #anchor and the target is Markdown, that a heading in it has that slug (repeated headings get the
    -1, -2 suffixes GitHub gives them). Each failure names the file, the link and the reason.
  • Links starting with a scheme (http:, https:, mailto:, and the like) are skipped; nothing is fetched.

Verification note

Proven to fail on purpose, then undone: pointing a link in CONTRIBUTING.md at docs/devices-missing.md failed with
CONTRIBUTING.md: link "docs/devices-missing.md" does not point at an existing file, and a wrong anchor failed with
CONTRIBUTING.md: link "docs/devices.md#run-it-on-an-iphone-wrong" points at an anchor no heading in docs/devices.md has.
No real broken link was found in the 84 tracked Markdown files, so no doc changes here.

In this Windows checkout the root scripts glob also shows one pre-existing failure in the devices table check
(docs/devices.md holds the table), untouched by this change; the new tests pass in that same run.

How to check

node --test scripts/docs-links.test.mjs
pnpm test

Keep in mind

  • No network: the test only reads files. No new dependency; a small hand-written parser for the links the docs use.

Pull request template

What and why

Closes #228.

Adds a test that every relative link and anchor in the tracked Markdown resolves.

Vision fit

Principle 4, honest about limits: a moved file or renamed heading in the contributor docs now fails a test instead of shipping.

Non-negotiables

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: n/a

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it. The test was written first and failed on the missing module; a broken file link and a wrong anchor in a real doc each failed naming the file and link, then were undone.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. Gate note: privacy and guard pass on this checkout today; the rest was run per package as listed under AI agents, not as one root gate on this Windows machine, where unrelated pre-existing failures appear in the site badges, the devices table and mobile source scans.
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with its host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.
  • Tests, fixtures and screenshots use made-up data only.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.

New dependencies and network calls

None. No new dependency and no new network call.

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Tinsel Alpha, an AI coding agent running in OpenCode, drafted the change and this description and ran the checks below, in a session directed by the author, who reviewed each step's report before it was pushed.
  • I read and ran everything in this pull request, and I can explain it.

What was run: node --test scripts/docs-links.test.mjs (8/8 over all 84 tracked Markdown files); the root scripts test glob (92 pass, 1 pre-existing devices-table failure in this Windows checkout).

@juancguerrerodev

Copy link
Copy Markdown
Contributor

Ready to merge once the pull request template is filled in, including the "I read and ran everything" box (details on #234). 🦀

@juancguerrerodev
juancguerrerodev merged commit e293cae into DojoCodingLabs:main Dec 6, 2026
4 checks passed
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.

Add a test that relative links and anchors in the docs work

3 participants