-
Notifications
You must be signed in to change notification settings - Fork 1
Add doctest infrastructure and validate code examples #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robtaylor
wants to merge
3
commits into
refactor/restructure-codebase
Choose a base branch
from
feature/doctest-improvements
base: refactor/restructure-codebase
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add doctest infrastructure and validate code examples #145
robtaylor
wants to merge
3
commits into
refactor/restructure-codebase
from
feature/doctest-improvements
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
fba3cf5 to
fd3a449
Compare
fbb8f64 to
4e33f5b
Compare
|
95acef4 to
126bd42
Compare
4e33f5b to
4a33a0d
Compare
b568bf8 to
1dc2906
Compare
4a33a0d to
9cc71c3
Compare
1dc2906 to
8397916
Compare
Phase 1 & 2 of doctest improvements: - Fix import path in chipflow-toml-guide.rst doctest (_parse_config_file from config.parser) - Add doctest_global_setup in conf.py with common imports for test examples - Existing doctest now passes The global setup imports common modules (Amaranth, ChipFlow signatures) so that doctests can focus on demonstrating API usage without repetitive imports. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Phase 3 of doctest improvements: - Convert complete MySoC examples to testcode blocks with assertions - Two examples converted: using-pin-signatures.rst and architecture.rst - Examples now validate that classes can be instantiated correctly - All doctests pass (3 tests total) Strategy: Convert only complete, self-contained examples that use documented public APIs. Keep illustrative fragments as code-block for readability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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>
62987f9 to
e7ef8c3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds doctest infrastructure to validate code examples in the documentation and fixes the existing failing test.
Branched from:
refactor/restructure-codebase(as requested)Changes Made
Phase 1: Fix Existing Failing Test ✅
chipflow-toml-guide.rstdoctestchipflow_lib.configtochipflow_lib.config.parserPhase 2: Add Doctest Infrastructure ✅
doctest_global_setupindocs/conf.pyPhase 3: Convert Strategic Examples ✅
.. code-block::to.. testcode::using-pin-signatures.rst: MySoC basic examplearchitecture.rst: MySoC with elaborate() examplePhase 4: Document Testing Strategy ✅
conf.pyexplaining the approachtestcodevscode-blockTesting Strategy
The approach balances automatic validation with documentation readability:
.. testcode::→ validated automatically.. code-block::→ kept for readabilityTest Results
All doctests pass:
Run tests with:
pdm test-docsBenefits
✅ Code examples are automatically validated against API changes
✅ CI can catch documentation that breaks with code changes
✅ Maintains documentation readability (no excessive test boilerplate)
✅ Clear guidance for contributors on which examples to test
What's Not Tested
By design, the following remain as illustrative
code-blockexamples:__init__calls, etc.)chipflow_digital_ip)This keeps docs readable while ensuring core public API examples are validated.
🤖 Generated with Claude Code