Playbook: documentation for the next microservice
This service is the reference implementation of the PVC three-layer documentation strategy. To set up the same thing in a new microservice, copy the pieces below. Each is small and works on its own.
1. Layer 3 first: make the compiler enforce it
In Directory.Build.props:
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- do NOT add CS1591 to NoWarn: a missing XML comment is a build error -->
Test projects set <GenerateDocumentationFile>false</GenerateDocumentationFile>. On an existing codebase, list the
gaps with dotnet build "-p:NoWarn=" -p:TreatWarningsAsErrors=false | grep CS1591, document them, then remove the
suppression.
2. OpenAPI from the code
builder.Services.AddOpenApi()plusapp.MapOpenApi(). With XML docs on, .NET 10 puts your<summary>and<param>text into the schema descriptions for free.- Every route:
.WithSummary("..."),.WithTags("..."), and.WithDescriptionwhen behaviour needs explaining. - Serve an interactive reference (Scalar:
app.MapScalarApiReference("/docs/api")). - Add a test that fails when an operation has no summary (copy
ApiDocsTests).
3. DocFX for the .NET reference
Copy build/docfx/ (config, index.md, toc.yml) and add docfx to dotnet-tools.json. Output to
wwwroot/docs/code (gitignored) and build it in CI and in the Dockerfile.
4. Layer 2: the handbook
Copy website/ (Docusaurus config and sidebar) and start docs/ from the templates:
docs/
intro.md where to look, reading paths
product/ the business problem, concepts, glossary
architecture/architecture-overview.md context, layers, a request end to end
architecture/decisions/ ADRs
services/<service>.md the service card
api/ auth, errors, idempotency (not the endpoint list: OpenAPI has it)
events/ one page per message + a catalog with the topology
database/ data model (ER), migrations, queries
developer-guide/ getting started, configuration, testing, docs, runbook, deployment
Set onBrokenLinks: 'throw' so a broken link fails the build.
5. Events: generate the tables, write the prose
Copy build/docs/event-pages.py and EventDocsTests. Contracts stay the source of truth for fields; people write
the when and what to do with it.
6. Make it part of every change
Copy .github/pull_request_template.md and CHANGELOG.md. Add a CI step that builds the handbook and DocFX.
Then work through the checklist.