Skip to content

Commit fbb8f64

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 9e5ba57 commit fbb8f64

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
@@ -96,6 +96,28 @@
9696
]
9797

9898
# Doctest configuration
99+
#
100+
# Strategy: Selective testing with infrastructure
101+
# ------------------------------------------------
102+
# We use Sphinx doctest extension to validate code examples in our documentation.
103+
# The approach balances completeness with maintainability:
104+
#
105+
# 1. Complete, runnable examples use `.. testcode::` and are validated automatically
106+
# 2. Illustrative code fragments remain as `.. code-block::` for readability
107+
# 3. Global setup (below) provides common imports to reduce boilerplate
108+
#
109+
# When to convert an example to testcode:
110+
# - Complete class definitions that can be instantiated
111+
# - Signature usage examples showing public API
112+
# - Self-contained examples using only documented public APIs
113+
#
114+
# When to keep as code-block:
115+
# - Incomplete fragments (e.g., just showing part of __init__)
116+
# - Examples requiring external dependencies (chipflow_digital_ip)
117+
# - Pseudo-code or conceptual illustrations
118+
#
119+
# Run tests with: pdm test-docs
120+
99121
doctest_global_setup = """
100122
from pathlib import Path
101123
from amaranth import Module

0 commit comments

Comments
 (0)