Skip to main content

How we document (docs-as-code)

This service follows the PVC three-layer documentation strategy (v1.0.0). Documentation lives in the repository, is reviewed with the code, and is published by the service itself under /docs.

LayerToolLives inPublished atEnforced by
1 · UI componentsStorybook——Not applicable (no UI components)
2 · Product and systemDocusaurusdocs/ (content), website/ (site)/docs/handbook/npm run build fails on broken links and anchors
3 · API contractOpenAPIEndpoint code (.WithSummary, XML docs on DTOs)/docs/api, /openapi/v1.jsonApiDocsTests: every operation has a summary
3 · .NET codeXML docs + DocFX/// comments in src//docs/code/CS1591 is a build error
Change historyGitPRs, CHANGELOG.mdGitHubPR template checklist
DataSQL comments, EF migrationsPersistence/Migrations, comments in raw SQLDatabaseReview

The workflow​

  1. Author. Change the code and the docs together. A new endpoint gets a summary. A new public member gets an XML comment. A new or changed message gets its event page. A new decision gets an ADR.
  2. Review. The reviewer reads the docs diff like the code diff. Is it true, and would a newcomer understand it?
  3. Verify. CI builds with docs warnings as errors, runs the docs tests, builds the handbook (broken links fail) and builds DocFX.
  4. Release. The Docker image builds the handbook and the .NET reference, so the deployed /docs always matches the deployed code.

What goes where​

  • "How does it work and why?" → the handbook (docs/).
  • "What does this field or method mean?" → an XML comment on it. It flows to OpenAPI, DocFX and IntelliSense.
  • "How do I call it?" → endpoint summary and description (OpenAPI).
  • "What happened to the data?" → the migration, and a -- comment in any raw SQL.
  • "What changed?" → the PR description and CHANGELOG.md.

Writing style​

Short sentences, present tense, active voice. Lead with what the reader needs. Use tables for reference material and Mermaid for flows. Name the real thing (TaxDocumentCommitted, tax:commit) instead of describing it.

Versioning​

Docs are versioned with releases. The handbook on main is Next. When the service is released:

cd website && npm run version -- 1.2.0 # snapshots docs/ into website/versioned_docs/version-1.2.0

Commit the snapshot in the release PR and add the release to CHANGELOG.md. The OpenAPI document and the .NET reference are always generated from the deployed build, so they version themselves.

Build the docs locally​

cd website && npm ci && npm start # live preview at http://localhost:3000/docs/handbook/
npm run build # what CI runs; output to wwwroot/docs/handbook
dotnet tool restore && dotnet docfx build/docfx/docfx.json # .NET reference → wwwroot/docs/code
python3 build/docs/event-pages.py # refresh event field tables from the contracts

Or all at once: build/docs/build.sh.

The pull request checklist​

The PR template (.github/pull_request_template.md) asks:

  • Public members have XML docs (the build enforces it)
  • New or changed endpoints have a summary and the right scope
  • Message contract changes: snapshot approved, event page updated (event-pages.py)
  • Schema changes: migration reviewed (dotnet ef migrations script --idempotent), data changes commented
  • Handbook pages updated for behaviour changes; an ADR for decisions
  • CHANGELOG.md entry under Unreleased