Skip to content

Add a Go linter for the docs/ content contract - #4584

Merged
kyleconroy merged 1 commit into
mainfrom
claude/docs-website-alternatives-naaa6t
Aug 26, 2026
Merged

Add a Go linter for the docs/ content contract#4584
kyleconroy merged 1 commit into
mainfrom
claude/docs-website-alternatives-naaa6t

Conversation

@kyleconroy

Copy link
Copy Markdown
Collaborator

Follow-up to #4583: docs/ is now validated in CI using Go and only Go.

The linter

internal/docs parses every page with goldmark (pure Go, CommonMark + GFM — the same parser Hugo uses) and enforces the contract an external site consumer relies on:

  • every page parses as GFM and starts with exactly one level-1 heading (the page title)
  • relative links and images resolve to files inside docs/; anchor fragments (config.md#database) are checked against GitHub-style heading slugs, including duplicate-heading -1 suffixes
  • every page appears exactly once in toc.yaml (section or unlisted), and every toc.yaml entry names a real file
  • no raw HTML or JSX, except HTML comments (git-cliff emits one in the changelog)
  • no MyST/Sphinx leftovers: :::{note} paragraphs and ```{note} fences are rejected with a pointer to GitHub alert syntax

It runs as TestDocs under plain go test ./..., reporting violations as file:line: message. A second test, TestLintViolations, pins the linter's own behavior against a synthetic tree that breaks each rule once. These are unit tests rather than endtoend cases because the contract is a property of the documentation tree, not of anything the sqlc CLI does.

What the linter caught

Running it against the existing docs found 24 real issues, all fixed here:

  • 8 MyST admonitions still using :::{note} / ```{note} (overrides, ci-cd, push, named_parameters) — converted to > [!NOTE] / > [!TIP]
  • 9 links that only resolved under Sphinx: extensionless (../howto/named_parameters) and .html (../guides/plugins.html) targets — now point at the actual .md files
  • 6 anchors that don't match GitHub slugging: #sqlc-db-prepare#sqlcdb-prepare (slashes are dropped), #rules-using-explain-output#rules-using-explain--output, #the-go-type-map#the-go_type-map, and two stale #with-other-tools fragments in the changelog now link to the page itself
  • 1 missing title: the embedding guide started with an #### heading instead of #

Dependencies

Adds github.com/yuin/goldmark (no transitive dependencies).

🤖 Generated with Claude Code

https://claude.ai/code/session_013XDcHxZk9UzfzMLayG66Zq


Generated by Claude Code

internal/docs validates the documentation source tree with goldmark and
runs from go test, so doc-breaking changes fail CI without any JavaScript
toolchain. It enforces the contract the external site consumer relies on:
every page parses as GFM and starts with exactly one level-1 heading;
relative links and images resolve to files inside docs/, with anchor
fragments checked against GitHub-style heading slugs; every page appears
exactly once in toc.yaml and every toc.yaml entry names a real page; no
raw HTML other than comments; and no leftover MyST directives.

Fix everything the linter found in the existing docs: convert the eight
remaining MyST admonitions to GitHub alert syntax, add the missing
level-1 heading to the embedding guide, point extensionless and .html
links (which only resolved under Sphinx) at the actual .md files, and
correct anchors that did not match GitHub slugging (#sqlcdb-prepare,
#rules-using-explain--output, #the-go_type-map, and stale
#with-other-tools fragments in the changelog).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XDcHxZk9UzfzMLayG66Zq
@kyleconroy
kyleconroy merged commit 7d33de9 into main Aug 26, 2026
12 checks passed
@kyleconroy
kyleconroy deleted the claude/docs-website-alternatives-naaa6t branch August 26, 2026 20:41
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