Lesson 6 of 9 · 27m
Build, Test, and Publish Documentation Automatically
Assemble a practical docs pipeline with build checks, link validation, prose linting, example testing, versioning, and observable publishing.
The purpose of docs automation is not to make writing feel like enterprise software. It is to remove entire classes of avoidable embarrassment: broken links, dead anchors, malformed samples, stale screenshots, missing pages, and publications that only work on the author's laptop. A good pipeline is boring, fast, and opinionated about the few checks that matter.
Start with a reproducible local build
The first automation requirement is that every author can run the same build:
git clone git@github.com:SudoSecurityOrg/Forums.git
cd docs
bun install
bun run buildPin the toolchain in package.json or a lockfile. Document prerequisites, but do not accept "install these eleven global tools manually" as a normal workflow. If the build cannot run in CI, local success is not meaningful.
Validate structure before style
A baseline CI job can be small:
name: docs
on:
pull_request:
paths: ["docs/**"]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: cd docs && bun install --frozen-lockfile
- run: cd docs && bun run build
- run: cd docs && bun run check:linksBuild first. Link check second. Prose linting after that. If the build fails, nothing else matters. If links fail, readers hit dead ends. Style issues are real but rarely as urgent.
Link checking needs operational care
Internal links and anchors can be checked deterministically. External links are flaky: sites rate-limit bots, require JavaScript, or block CI networks. Treat external failures differently:
lychee --offline --include-fragments 'docs/**/*.md'
lychee --exclude-loopback --retry 2 --timeout 10 'docs/**/*.md'Do not teach the team to ignore red CI by allowing permanent noise. Maintain a narrow exclusion list with comments explaining why each entry exists.
Test examples as artifacts
A powerful pattern is to store examples as files and include them in prose: Then test what can be tested:
python3 -m json.tool examples/create-workspace.json >/dev/null
bash -n examples/rotate-token.sh
hardline audit --config examples/minimal-hardline.toml --check-onlyNot every example can execute in CI. Some need cloud credentials or production infrastructure. In those cases, create fixture-backed tests or a clearly labeled smoke environment. Syntax checking is better than nothing, but behavior checking is the goal.
Prose linting should enforce decisions, not taste
Vale and similar tools are useful when they encode agreed rules: product names, banned terms, insecure terminology, heading capitalization, or required alt text. A bad ruleset produces a stream of nitpicks and trains authors to ignore it. Start with rules that prevent actual harm:
Hardline, not hard line
API token, not API key when referring to bearer tokens
Use "allowlist" and "denylist" in new documentation
Every image requires alt textPublishing is part of the pipeline
A merge is not publication if deploys are manual and invisible. Record the source revision, build hash, deploy target, and rollback path. Preview branches help review, but production publication should be explicit. For versioned products, publish matching documentation versions and make the default version obvious.
Field notes
- Fast checks keep trust; if docs CI takes twenty minutes, authors will route around it.
- Cache dependencies, but never cache generated content in a way that hides changed source files.
- Generated reference must be reproducible in CI or it will drift into hand-edited mush.
- Publish logs should be visible to documentation owners, not only platform engineers.
Was this lesson helpful?