Unify doctest replay extraction and fix installed-package bootstrap#13
Conversation
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:. Includes naming-shaped doctest tests and an installed-package integration test with relative imports in __init__.py. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Documentation build overview
|
Remove strip_doctest_prompts fallback and extract_doctest_source alias. DocTestParser is the sole conversion path for both autodoc blocks and py-repl directive bodies. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
|
@cursoragent review |
PR Review: Unify doctest replay extraction and fix installed-package bootstrap (#13)Verdict: Approve — ready to merge into This PR cleanly addresses both naming bugs with a smaller, more coherent surface area than the original monkey-patch approach. RTD preview builds successfully. What works wellUnified extraction — Blank-line joining — Installed-package bootstrap — Replacing Net reduction — ~53 lines removed overall despite adding tests. Matches the stated preference for minimal, debt-free code. Tests — 20/20 pass locally. Coverage spans unit (extraction), integration (autodoc scope, in-tree Minor cleanup (optional, can follow up)
None of these block merge. Confirmed against naming issues
After this merges into the autodoc branch and naming drops Summary
Recommendation: Merge into |
Drop generated -bootstrap.py support from register_autodoc_repl and simplify _resolve_autodoc_bootstrap to return (src, packages) only. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Autodoc doctest conversion is now disabled unless clients set pyrepl_doctest_blocks to "autodoc" or "all". Extension docs and autodoc tests opt in explicitly. 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>
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>


Summary
Phase 2 follow-up for autodoc REPL integration, addressing the two bugs found when building the naming docs.
1. Unified
doctest_to_replay_source()Single conversion function for both autodoc doctest blocks and
.. py-repl::directive bodies:doctest.DocTestParseronly — strips expected output, splits examples, joins with blank linesstrip_doctest_prompts()andextract_doctest_source()2. Installed-package bootstrap via
packages=For modules outside the Sphinx source tree, autodoc REPLs emit
packages="<top-level module>"(micropip) instead of exec'inginspect.getsource(). In-tree demo modules still use silent:src:.Tests
Follow-up
After merge, naming can drop the temporary
pyrepl_autodoc_fix.pymonkey-patch (PR chrizzFTD/naming#31).