Config-driven autodoc packages via wheel path#17
Conversation
Replace module introspection and silent :src: bootstrap for autodoc REPLs with a single pyrepl_autodoc_packages config value. Remove pyrepl_autodoc_bootstrap. Move the autodoc doctest example into pyrepl_test_pkg, rebuild the committed wheel fixture, and add scripts/build_test_pkg_wheel.py. Wire the fixture into the [docs] optional extra for one-command local and RTD doc builds. Update docs, README, and tests to match the wheel-based autodoc workflow. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Documentation build overview
|
|
@cursoragent review |
PR Review: #17 — Config-driven autodoc packages via wheel pathVerdict: Approve. This delivers the planned simplification cleanly and stacks well on #16. RTD preview build succeeded. What works wellArchitecture. Replacing ~45 lines of module introspection with a 3-line config lookup is the right trade-off. One mechanism (wheel/ Config design. Collapsing def _autodoc_packages(app: Sphinx) -> str | None:
"""Return configured package preload for autodoc doctest REPLs."""
return app.config.pyrepl_autodoc_packages or NoneUnset → replay only. Set → preload. No ambiguous half-states. Option B. The docs = [
"myst-parser",
"pyrepl_test_pkg @ file:./tests/fixtures/pyrepl_test_pkg",
]Tests. Good coverage of the three behaviors that matter: packages emitted, packages regardless of module location, replay-only when unset. The Tooling. Docs narrative. Autodoc and local-wheel examples now tell one coherent story via Issues / nits1. Dead code:
|
| Step | Status |
|---|---|
| #16 merged first | prerequisite |
pytest (26 passed) |
done |
| RTD preview (#17) | passed |
Manual: autodoc REPL loads pyrepl_test_pkg from wheel |
still open |
Summary
The PR achieves the design goals: minimal extension code, no introspection debt, single config knob, fixture consolidated under pyrepl_test_pkg, Option B for doc builds. I'd merge after #16 with at most a quick dead-code cleanup for register_startup_file.
Want me to push a small follow-up commit removing register_startup_file before merge?
When pyrepl_autodoc_packages is set, generate a silent bootstrap script that imports the documented object from autodoc desc_signature metadata before replaying doctest input. This lets unqualified doctest names like example_generator work without changing docstrings. Bootstrap scripts are written alongside replay files under _static/pyrepl/ and emitted as src= on autodoc py-repl widgets. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
PR #18 merged auto-import bootstrap that emits silent src= bootstrap scripts alongside packages=. The prior cleanup commit removed the src parameter from make_pyrepl_raw, causing TypeError in transform_doctest_blocks and failing CI/RTD builds. Co-authored-by: chrizzftd <chrizzFTD@users.noreply.github.com>
|
@cursoragent review |
PR Review: #17 (current state) — Config-driven autodoc packages via wheel pathVerdict: Approve. CI/RTD are green again. The branch now delivers both #17 (wheel preload) and #18 (auto-import bootstrap) as a coherent autodoc story. What changed since the first reviewThe branch picked up #18 after the initial review, then a cleanup commit briefly broke builds by removing Current autodoc REPL behavior (when
Unset What works wellArchitecture. The old introspection path is gone. Replacement is two small, explicit mechanisms:
No copying source files from arbitrary module locations. #17 + #18 fit together. Bootstrap imports only run when Bootstrap source logic is simple and testable: def autodoc_bootstrap_source(
module: str | None,
fullname: str | None,
objtype: str | None,
) -> str | None:
...
if "." in fullname:
root = fullname.split(".", 1)[0]
return f"from {module} import {root}\n"Methods get their enclosing class imported, which is the right default for unqualified doctest names like Tests. 31 passed (up from 26). Coverage spans packages emission, out-of-tree modules, replay-only fallback, bootstrap script content, and Infra. RTD preview build succeeded on Docs/README already describe the combined behavior (wheel + auto-import). Issues / nits1. PR description is stale (update before merge)The PR body still describes #17 only — no mention of #18's auto-import bootstrap or the
Worth updating the description so reviewers and future readers aren't confused. 2.
|
| Item | Status |
|---|---|
Dead register_startup_file |
Removed ✓ |
make_pyrepl_raw src param |
Correctly kept for #18 bootstrap ✓ |
| CI/RTD failures | Fixed (c6dcd98) ✓ |
Merge checklist
| Step | Status |
|---|---|
| #16 merged first | prerequisite |
pytest (31 passed) |
✓ |
| RTD preview | ✓ (build #33401240) |
| PR description updated | recommended |
| Manual: autodoc REPL loads package + runs doctest | still open |
Summary
The branch is in good shape to merge after #16. The design is cleaner than the original introspection approach, and #18's auto-import layer makes the wheel-based model actually usable with standard unqualified doctest examples.
Recommended before merge: update the PR description to reflect the combined #17+#18 behavior. Everything else is non-blocking.
b773213
into
cursor/autodoc-bootstrap-src-only-16b5


Summary
Stacks on #16. Replaces autodoc module introspection and silent
:src:bootstrap with a single config knob,pyrepl_autodoc_packages.pyrepl_autodoc_bootstrapand_resolve_autodoc_bootstrap(importlib/inspectgone)pyrepl_autodoc_packages— when set, every autodoc doctest REPL getspackages=from config; when unset, replay onlypyrepl_test_pkg(demo.example_generator); rebuild committed wheel fixturescripts/build_test_pkg_wheel.pyto rebuild/copy the fixture wheelpyrepl_test_pkg @ file:./tests/fixtures/pyrepl_test_pkgto[docs]extra for one-commandpip install -e ".[docs]"(local + RTD)Behavior
pyrepl_autodoc_packagesNone/""packages=from configAutodoc assumes a single documented package. Host build still imports it normally; the browser REPL preloads via the configured wheel.
Test plan
pytest— 26 passedpyrepl_test_pkgfrom wheel after deploy