Skip to content

Commit e7ef8c3

Browse files
robtaylorclaude
andcommitted
Document doctest strategy with comprehensive comments
Phase 4 of doctest improvements: - Add detailed comments in conf.py explaining testing philosophy - Clarify when to use testcode vs code-block - Document the selective testing approach for maintainability - Provide guidance for future contributors The strategy balances automatic validation with documentation readability, testing complete examples while keeping fragments illustrative. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 48a882c commit e7ef8c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/conf.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@
109109
]
110110

111111
# Doctest configuration
112+
#
113+
# Strategy: Selective testing with infrastructure
114+
# ------------------------------------------------
115+
# We use Sphinx doctest extension to validate code examples in our documentation.
116+
# The approach balances completeness with maintainability:
117+
#
118+
# 1. Complete, runnable examples use `.. testcode::` and are validated automatically
119+
# 2. Illustrative code fragments remain as `.. code-block::` for readability
120+
# 3. Global setup (below) provides common imports to reduce boilerplate
121+
#
122+
# When to convert an example to testcode:
123+
# - Complete class definitions that can be instantiated
124+
# - Signature usage examples showing public API
125+
# - Self-contained examples using only documented public APIs
126+
#
127+
# When to keep as code-block:
128+
# - Incomplete fragments (e.g., just showing part of __init__)
129+
# - Examples requiring external dependencies (chipflow_digital_ip)
130+
# - Pseudo-code or conceptual illustrations
131+
#
132+
# Run tests with: pdm test-docs
133+
112134
doctest_global_setup = """
113135
from pathlib import Path
114136
from amaranth import Module

0 commit comments

Comments
 (0)