Skip to content

fix(check-docs): ignore link-shaped text in inline code spans without hiding real links - #216

Merged
bketelsen merged 3 commits into
mainfrom
lucilla/check-docs-code-spans
Nov 6, 2026
Merged

bketelsen merged 3 commits into
mainfrom
lucilla/check-docs-code-spans

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

scripts/check-docs.mjs read link-shaped text inside inline code as a link. A Go generic call in a code span, such as errors.AsType[T](err), failed the gate as a broken link (#201).

The gate now skips a link-shaped match only when CommonMark would render it as code. The rule is conservative: a real link is never hidden.

  • Code spans are computed on the original text, never on fence-stripped text. A removed fence chunk can join 2 backticks into a false span.
  • Spans count only in a safe run of non-blank lines (a blank line has only spaces and tabs; CR, LF and CRLF end a line). A run is unsafe, and every link in it stays checked, when it has a | (GFM table cells), a backslash before a backtick (escaped backtick), a < with a later > (raw HTML and autolinks bind before code spans), a line with an unpaired backtick run (wrapped spans, adjacent headings, run-length mismatch), or a marker outside every span with a later backtick: ]( or ][ (a link destination, title or reference label consumes the backtick), www. or :// (a GFM extended autolink path does too), or $ (GitHub inline math). In a safe run, each line pairs runs of equal length left to right, which is CommonMark's own pairing.
  • A match is skipped only when its whole original range is inside 1 span. A match that crosses a removed fence chunk or a span boundary is still checked.
  • Fence and HTML comment stripping are unchanged. The index check uses the same rule, so a link in a code span in docs/README.md no longer indexes a doc (stricter only).

Guard tests in test/docs-integrity.test.mjs cover every case the #200 review found against the earlier stripper (escaped backticks, run lengths, adjacent headings, wrapped spans, GFM tables, raw HTML, email autolinks), a code span in link text, 2 fence-mapping cases (a chunk removed mid-line, a list-item fence), backticks consumed by a link destination, title, reference label, GFM autolink or inline math, a U+00A0 line, a lone CR, index coverage, and 6 passing cases (generic calls, a run-length span, Go <1.26 with a span, CRLF, :// inside a span). .memory/corrections.jsonl gets 1 docs-gate line.

The 3 split generic calls in the vendored Go skills stay for now. The docs gates of updex and std check every Markdown file, synced skills included, and do not read code spans yet. If core removed the overrides first, the skills-sync PRs to those repositories would fail. docs/design/shared-skills.md now says this. A later PR removes the overrides once those gates read code spans.

Refs #201 (it stays open for the override removal).

Risk tier

Risk tier: 2 — a change to a quality gate (scripts/check-docs.mjs) and its tests. No path in .github/risk-paths.json matches. No workflow or skills-sync change.

Docs housekeeping

  • Cross-links hold (docs/design/shared-skills.md edited in place; no new doc)

Verification

  • node scripts/check-docs.mjs green: checked: 101 docs, 1912 links, 10 symlinks (same counts as before)
  • make verify: 414 tests pass; CI green at f21f24b
  • Docs-site scaffold tests green
  • Manual proof: in a temporary copy with the 3 generic calls joined into 1 code span each (overrides removed), the gate passes at 1.000
  • Revert test, scratch worktree at f21f24b, node --test test/docs-integrity.test.mjs with only scripts/check-docs.mjs replaced:
    • from the base 6cf5b09: 6 tests fail on assertions (index coverage in a code span, Go generic calls, run-length span, < without >, CRLF pairing, :// inside a span). The must-fail cases pass there, because the base gate checks every match.
    • from 3dc57b1 (before the review fixes): 8 tests fail on assertions (link destination, link title, full reference label, U+00A0 line, lone CR, www. autolink, https:// autolink, inline math).

Cross-review

Reviewer: openai/gpt-6.1-sol. Coder: github-copilot/mai-code-2-flash.

  • 3dc57b1: Not ready. 3 blocking points (a backtick in a link destination, a U+00A0 line and a lone CR could each hide a real link). All 3 were fixed in 3e99020 with guard tests, plus GFM autolinks and inline math in f21f24b.
  • f21f24b: Ready. Blocking: none.

… hiding real links

A generic Go call in inline code, such as `errors.AsType[T](err)`, matched
the link pattern and failed the gate as a broken link (core#201).

The gate now skips a link-shaped match only when its whole original range
is inside a code span of a safe run of non-blank lines. A run with a `|`,
an escaped backtick, a `<` with a later `>`, or a line with an unpaired
backtick run keeps every link checked. Spans are computed on the original
text, never on fence-stripped text. Fence and comment stripping are
unchanged.

The guard tests cover each case the core#200 review found, plus 2 cases
from the fence mapping. The 3 split calls in the vendored Go skills stay
until the updex and std docs gates read code spans too.
@bketelsen
bketelsen merged commit 4d8890e into main Nov 6, 2026
5 checks passed
@bketelsen
bketelsen deleted the lucilla/check-docs-code-spans branch November 6, 2026 19:16
bketelsen pushed a commit that referenced this pull request Nov 6, 2026
The docs gates of core, updex and std now ignore link-shaped text inside
an inline code span (#216, frostyard/updex#493, frostyard/std#99), so the
vendored Go skills no longer need the split `X[T]`(`v`) form. Restore
upstream's single code span in golang-error-handling, golang-safety and
golang-modernize/references/versions.md, drop the 3 marked override
comments, and drop the Code spans entry from the overrides list.

Closes #201.

Co-authored-by: frostyard-machines <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants