ADR-012: Living Documentation
Status
Accepted
Context
Static documentation becomes stale over time:
Available actions in ActionRegistry change as new features are added
Mouse profiles in MouseDefinitions are updated with new devices
Screenshots may not reflect current UI state
Manual documentation updates are error-prone and often forgotten
We need a documentation strategy that keeps reference documentation synchronized with the actual code and data.
Decision
We will generate reference documentation from tests that introspect actual code and data.
Documentation Generation Pattern
Test introspects source of truth
test_generate_mouse_profiles.pyreads JSON files fromMouseDefinitions/test_generate_actions_reference.pyintrospectsActionRegistrytest_tutorial_workflow.pycaptures screenshots during actual workflows
Test generates RST files
Output goes to
docs/reference/_generated/ordocs/user-guide/_generated/Generated files are gitignored (not committed)
Static RST files use
.. include::directives to pull in generated content
CI runs tests → builds docs
GitHub Actions runs generation scripts as part of build
Sphinx build includes freshly generated content
Documentation artifacts include current generated content
What Gets Generated
Source |
Generator |
Output |
|---|---|---|
|
|
|
|
|
|
UI workflow |
|
|
Generator Requirements
Mouse Profiles Generator: Can run standalone (Python only, reads JSON)
Actions Generator: Requires Slicer context (imports ActionRegistry)
Tutorial Generator: Requires Slicer with UI (captures screenshots)
Consequences
Positive
Documentation always matches current code and data
Tests verify documentation is generatable (catches import errors, missing data)
Single source of truth (code/data defines behavior AND docs)
No manual documentation updates for routine changes
CI catches documentation generation failures
Negative
Generated documentation must be excluded from git (requires
.gitignoreupdate)Local development requires running generators to preview docs
Slicer-dependent generators require full Slicer environment
Neutral
Documentation build becomes dependent on test execution
Some documentation remains static (conceptual guides, tutorials prose)
Trade-off between flexibility (static docs) and accuracy (generated docs)
Implementation
Create
test_generate_mouse_profiles.py(standalone Python)Create
test_generate_actions_reference.py(requires Slicer)Update
docs/reference/to include generated contentAdd
docs/reference/_generated/to.gitignoreUpdate CI workflow to run generators before Sphinx build
Update existing RST files to use
.. include::directives