golem doctestDoctest & Code Example Verification
Verifying Executable Code Examples
Technical documentation easily becomes stale when APIs change. Golem integrates with asciidoctest to parse and execute Python code blocks embedded within AsciiDoc documents.
Run doctest verification across your documentation:
Test Block Roles & State Models
Golem's doctest plugin supports advanced state management and isolation models:
Isolated Blocks (Default)
By default or when marked with [source,python,role="test"], blocks run in isolated, ephemeral state:
[source,python,role="test"]
....
>>> a = 10
>>> a * 2
20
....Section Boundary Scoping
Shared state automatically resets at top-level section boundaries (==), isolating independent document chapters or topics while preserving sequential state flow within each section.
Named Context Scopes
Manage multiple independent timelines within a single document using named contexts:
[source,python,shared="server"]
....
port = 8080
....
[source,python,shared="client"]
....
timeout = 30
....Explicit Reset Markers
Clear all accumulated shared state and named contexts on demand using [source,python,reset].