Add opt-in autodoc integration for Example doctest blocks (v0.2.0)#11
Add opt-in autodoc integration for Example doctest blocks (v0.2.0)#11chrizzFTD wants to merge 3 commits into
Conversation
Implement issue #9: convert autodoc docstring Example/Examples sections into interactive py-repl directives at Sphinx build time. - Add extract_doctest_inputs() to strip expected output and tracebacks - Add autodoc-process-docstring hook with pyrepl_autodoc config values - Extract register_replay_script() helper from PyRepl.run() - Add unit and integration tests for autodoc conversion - Document autodoc integration and limitations in README Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
….2.0)" This reverts commit bfb17f2.
…0.2.0)" This reverts commit bbb8ec8.
Documentation build overview
|
|
@cursoragent review |
PR Review: #11 — Autodoc integration (v0.2.0)Verdict: Approve with minor suggestions. The implementation matches issue #9, is opt-in and backward compatible, and the test coverage is solid for the naming downstream case. RTD preview build succeeded. What works wellArchitecture — Directive injection via
Integration test — Full Documentation — README config table and v0.2.0 limitations (Napoleon, packages, live output differences) are accurate and honest. Non-blocking suggestions1. Private cross-module import
2. Hard-coded _DEFAULT_WHAT = frozenset({"class", "function", "method"})Module docstring 3. Package auto-derivation is untested in integration Unit test covers 4. Section header case sensitivity
5. Git history noise The branch has commit → revert → reapply. Recommend squash merge to keep 6. Pre-existing (not introduced here)
Risks accepted (documented, OK for merge)
Test summaryMissing but not blocking: multiple RecommendationMerge after squash. This unblocks naming to enable: pyrepl_autodoc = True
pyrepl_autodoc_packages = "naming"
pyrepl_autodoc_sections = ["Example"]
pyrepl_autodoc_options = {"no-banner": True}No code changes required before merge unless you want to address the private-import or auto-derive test items in this PR. |
|
Implemented in #12 |


Summary
Closes #9. Adds optional autodoc integration so Sphinx projects can automatically convert docstring
Example:/Examples:doctest blocks into interactivepy-replwidgets at build time — without duplicating examples into RST or stripping expected outputs from Python source.Changes
sphinx_pyrepl_web/doctest.py—extract_doctest_inputs()strips expected output and traceback blocks while preserving>>>/...input lines (including bare...terminators)sphinx_pyrepl_web/autodoc.py—autodoc-process-docstringhook injects.. py-repl::directives into matching docstring sectionssphinx_pyrepl_web/__init__.py— extractregister_replay_script()helper; wire autodoc registration; bump version to 0.2.0autoclassConfig (opt-in, default off)
Testing
pytest tests/)<py-repl>HTML + replay scripts compile cleanly).. py-repl::directive behavior unchangedLimitations (documented)
sphinx.ext.napoleonsupport yet):packages:required (or auto-derived from object name) for Pyodide importPosixPathvsWindowsPath)Downstream
Enables naming to enable autodoc REPLs on
Name,File,Pipe, andPipeFileautoclass pages after bumping tosphinx-pyrepl-web>=0.2.0.