Add autodoc doctest_block REPL integration#12
Conversation
Transform doctest blocks inside autodoc API entries into interactive py-repl widgets using stdlib doctest.DocTestParser for source extraction. - Add pyrepl_doctest_blocks config (default: autodoc) - Refactor register_replay_script() shared by directive and transform - Remove unused :strip-prompts: option - Add tests and docs with example_generator demo Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Documentation build overview
|
Move doctest_block transform from doctree-resolved to doctree-read. env-updated (which writes replay scripts) runs after read but before write, so metadata registered during doctree-resolved was too late. Add regression test for include:: pattern used on RTD docs. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Load the documented module's source before replaying doctest examples, using the existing src + replay-src pattern from pyrepl-web. - Modules under srcdir: reuse the source file via :src: - Modules elsewhere: generate a bootstrap script in _static/pyrepl/ - Prefer sys.modules (already imported by autodoc) over re-import - Add pyrepl_autodoc_bootstrap config (default: True) Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
CI sets PYTHONWARNINGS=error; Napoleon triggers RemovedInSphinx11Warning during autodoc integration tests. Filter this upstream deprecation until Napoleon is updated. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
|
@cursoragent review |
PR Review: Add autodoc doctest_block REPL integration (#12)Verdict: Approve with one fix recommended before merge This is a solid, low-maintenance integration. It reuses existing machinery well, tests are thorough, and the RTD preview confirms the happy path works. One functional bug should be addressed; the rest are minor polish items. What works wellArchitecture — Transforming Source extraction — Using Bootstrap — Reusing the existing silent Tests — Good coverage: unit tests for extraction, integration for scope modes, include-pattern regression, bootstrap paths (srcdir vs generated), and on-disk file assertions. 21 tests, 96% coverage, CI command passes locally. Docs — README and live RTD example with Bug: JS not loaded on autodoc-only pages
So on a page with only Verified locally: metadata has This does not affect the docs site because Suggested fix — in if replaced:
env.metadata[docname]["pyrepl"] = True
doctree["pyrepl"] = TrueOr swap handler order / merge the two Minor issues
Out of scope (fine for v1)
Summary
Recommendation: Fix the |
transform_doctest_blocks runs after doctree_read on the same event, so autodoc-only pages never got doctree["pyrepl"] set and pyrepl.js was omitted from HTML output. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
) * Unify doctest replay extraction and fix installed-package bootstrap Add doctest_to_replay_source() as the single conversion path for both autodoc doctest blocks and py-repl directive bodies. DocTestParser strips expected output and joins separate examples with blank lines so multiline class definitions remain valid Python. For installed modules outside the Sphinx source tree, autodoc REPLs now emit packages= via micropip instead of exec'ing module source (which fails for packages with relative imports). In-tree modules still use silent :src:. --------- Signed-off-by: Christian López Barrón <chris.gfz@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
|
@cursoragent review |
PR Review: Add autodoc doctest_block REPL integration (#12)Verdict: Ready to merge Since the first review, the blocking issues have been addressed. The PR is in good shape for merge. Resolved since first review
What still works well
Remaining nits (non-blocking)
Summary
Recommendation: Merge. Optional follow-up: refresh the PR description to reflect |
- logger.error when autodoc REPL bootstrap cannot resolve module source - Fix docstring conversion sentence in README - Add test for bootstrap failure logging Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>


Summary
Testing
All 21 tests pass, including new autodoc integration and scope tests.