Skip to content

feat(docs): add offline link and accessibility checks for the public site - #18

Open
dchaudhari7177 wants to merge 1 commit into
esherialabs:mainfrom
dchaudhari7177:feat/public-docs-link-a11y-check
Open

dchaudhari7177 wants to merge 1 commit into
esherialabs:mainfrom
dchaudhari7177:feat/public-docs-link-a11y-check

Conversation

@dchaudhari7177

Copy link
Copy Markdown

Closes #6

npm run docs:public:check — one pass over both surfaces, offline.

Clean on the current tree:

$ node scripts/saferide-public-docs-check.mjs
public docs check: 11 markdown file(s) and 1 page(s) OK

What it checks

Links — every internal [text](path) and <a href> in docs/open-source/**.md and docs/open-source/site/*.html must resolve to a file that exists.

Link text — a label from a small closed set (click here, here, read more, …) is rejected. Someone tabbing a page hears the links out of context, so three "click here"s are three identical destinations as far as they can tell.

Page accessibility — four rules, each a regression a documentation edit can plausibly cause and each decidable from the markup: exactly one main landmark, a non-empty <title>, a lang on <html>, and an alt on every image.

Determinism, which is the constraint that shaped it

External URLs, mailto:, protocol-relative and same-page anchors are deliberately not resolved. Fetching them is the obvious way to write a link checker and the reason most of them get disabled: a gate that needs the network fails for reasons unrelated to the change under review. Every rule here is answered from files in the checkout, so the same tree gives the same verdict anywhere. There is a test asserting that.

The rules live in scripts/lib/saferide-public-docs.mjs returning findings, with a thin CLI in scripts/saferide-public-docs-check.mjs — matching the lib/ + entry-point split the other validators use, and letting the tests call the rules directly.

Acceptance criteria

Validate links in docs/open-source and the static site ✅ both, Markdown and HTML
One main landmark, unique page title, language metadata, meaningful link text ✅ plus missing alt
Deterministic and runnable without network access ✅ nothing opens a socket; asserted
Tests over one passing and one failing fixture scripts/__tests__/fixtures/public-docs/{passing,failing}/
Document the command in the public build guide ✅ new Documentation checks section in docs/open-source/build-and-test.md

The fixtures

The failing one breaks every rule exactly once, and the test asserts each message individually rather than just counting — so a fixture edit that quietly disables a rule fails the suite instead of reducing coverage silently:

docs/open-source/build-and-test.md:3 - broken link: ../../PROJECT_CHARTER.md
docs/open-source/README.md:5 - broken link: setup-guide.md
docs/open-source/README.md:7 - link text says nothing out of context: "click here"
docs/open-source/README.md:9 - link text says nothing out of context: "read more"
docs/open-source/site/index.html:8 - broken link: missing.html
docs/open-source/site/index.html:9 - link text says nothing out of context: "here"
docs/open-source/site/index.html - no main landmark: a keyboard user cannot skip to the content
docs/open-source/site/index.html - no page title: the tab and the browser history read as the URL
docs/open-source/site/index.html - no lang on <html>: a screen reader guesses the pronunciation
docs/open-source/site/index.html:7 - image with no alt attribute

13 tests. Beyond the two fixtures they cover the exclusions individually (external, mailto:, protocol-relative, same-page anchor, fragment-on-a-real-file), that a repeated broken target is reported once per file rather than once per occurrence, that trailing punctuation does not hide here., that site/ is not walked as Markdown, and that the real docs/open-source/ passes — a gate that does not hold on the tree it is added to is not a gate.

CI

Added to public-docs.yml before the site is assembled, so a broken link stops the deploy rather than shipping. actions/setup-node is SHA-pinned to match the existing steps in that file.

Verification

npm run docs:public:check — check clean, 13 tests pass. Also ran the CLI against both fixtures directly via --root, which is how I confirmed the failing one exits 1.

…site

Covers both surfaces in one pass: the Markdown under docs/open-source
and the static site in docs/open-source/site.

Broken internal links, link text that says nothing read out of context,
and four page-level regressions a documentation edit can plausibly
cause -- exactly one main landmark, a non-empty title, a lang on <html>,
an alt on every image.

Deterministic and offline by construction. External URLs, mailto: links
and same-page anchors are deliberately not resolved: a gate that needs
the network fails for reasons unrelated to the change under review.

Wired into public-docs.yml before the site is assembled, so a broken
link stops the deploy rather than shipping. Runs clean on the current
tree -- 11 markdown files and 1 page.
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 accessibility and link checks for the public documentation site

1 participant