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 |
drusite agent | The agent device’s command line, crates/drusite-agent/src/cli.rs |
Don’t edit these pages: change the doc comments in the code, then run
cargo xtask docs
which 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 mdBook from docs/, with the
table of contents in docs/SUMMARY.md, and published to GitHub Pages by
.github/workflows/docs.yml on every push to main. To preview it:
mdbook serve --open
mdBook is a single Rust binary (cargo install mdbook, or your package manager’s), its pages are
plain Markdown that also read well on GitHub, and it has search built in.
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.