Keeping these docs current
Docs that drift from the code are worse than none: they send people down paths that no longer exist. So the parts of these docs that describe the code are made from it or checked against it, and CI fails when they disagree.
What’s generated
| Page | Made from |
|---|---|
| Configuration | The server’s config types and their doc comments, in crates/drusite-server/src/config.rs, through a JSON Schema |
drusite-server |
The server’s command line, crates/drusite-server/src/cli.rs |
Don’t edit these pages: change the doc comments in the code, then run
cargo xtask docswhich writes them again and runs every check below. Commit the result with the code change.
What’s checked
cargo xtask docs --check runs crates/drusite-server/tests/docs.rs, which CI’s Docs
workflow runs on every pull request too. It fails when:
- a generated page differs from what the code makes now;
- a config key or a command-line argument has no doc comment, so its reference row would say nothing;
- any page (these docs, the README,
CONTRIBUTING.md,SECURITY.md) names a setting the server doesn’t have: aDRUSITE__…variable, a table and key in backticks (such as[auth.password] enabled), or a key in a TOML example (which must also parse); - a page names a
DRUSITE_…variable that nothing in the code, the images, the deployment files or the workflows reads; - the Helm values reference and the chart’s
values.yamldon’t list the same values; - the README’s download links aren’t for the workspace’s version (on a stable version);
- a relative link points at a file that isn’t there.
The phase plans under History aren’t checked: they record what was planned at the time.
The site
The site is built with Astro Starlight from docs-site/, which
reads the pages where they are, in docs/, with the table of contents in docs/SUMMARY.md. It is
published to GitHub Pages by .github/workflows/docs.yml on every push to main. To preview it,
with Node.js:
cd docs-site && npm ci && npm run devand open http://localhost:4321. It reloads as you edit a page. npm run build then
npm run check builds the site as CI does and checks that every link between pages resolves and
every published address still answers.
The pages stay plain Markdown that reads well on GitHub too, with no frontmatter:
- a page’s title is its first
# heading, and its sidebar label is its line inSUMMARY.md; - a new page needs a line in
SUMMARY.md, or it isn’t built; - link to other pages by their
.mdfile (../using/install.md); the site turns that into the page’s address (/using/install.html). Released apps link to those.htmladdresses, so a page that moves leaves a redirect behind, inREDIRECTSindocs-site/astro.config.mjs.
Writing for these docs
- Say what something does and why before how; then the steps, then how to check it worked.
- Use
example.comandexample.testfor every host and address. Every provider in an example is one choice among many: say so, and show more than one where it matters. - Quote messages exactly as the code writes them, so people can search for what they see.
- When a feature changes, change its page in the same pull request.