sphinx-pyrepl-web
Sphinx extension to embed pyrepl-web in documentation.
Install
pip install sphinx-pyrepl-web
Usage
Add the extension to the target project's conf.py module:
extensions = [
"sphinx_pyrepl_web",
]
Embed a REPL with the py-repl directive:
.. py-repl::
.. py-repl::
:theme: catppuccin-latte
:no-header:
.. py-repl::
:src: setup.py
:packages: numpy
.. py-repl::
:no-header:
>>> import math
>>> math.sqrt(16)
Directive options
All options drive pyrepl-web's attributes:
| Option | Description |
|---|---|
:theme: |
Color theme (catppuccin-mocha, catppuccin-latte) |
:packages: |
Comma-separated PyPI packages, URLs or relative wheel paths |
:repl-title: |
Title in the REPL header |
:src: |
Path to a Python startup script |
:replay: |
Replay :src: with interactive prompts instead of silent load |
:no-header: |
Hide the header bar |
:no-buttons: |
Hide copy/clear buttons |
:readonly: |
Disable input |
:no-banner: |
Hide the Python version banner |
Sphinx options
Enable doctest style examples conversion into pre-configured interactive REPLs with:
pyrepl_doctest_blocks:
| Value | Outcome |
|---|---|
False (default) |
Don't convert doctest blocks |
"autodoc" |
Convert doctest blocks from autodoc |
"all" |
Convert all doctest blocks |
pyrepl_autodoc_packages:
| Value | Outcome |
|---|---|
None (default) |
Replay doctest input without preloading packages |
:project: |
Build a wheel from the documented project and preload it |
| Wheel path / PyPI names | Install the package and import the documented object before replay |
Optional when using :project::
| Value | Default | Outcome |
|---|---|---|
pyrepl_project_root |
auto-detect | Project root containing pyproject.toml (relative to conf.py) |
pyrepl_wheel_dir |
_static/wheels |
Directory for the built wheel, relative to conf.py |
Local wheels
Unreleased package wheels can be available in the REPL by building them under Sphinx's html_static_path, or by using :project: to build automatically at doc-build time.
All options combined:
extensions = [
"sphinx.ext.autodoc",
"sphinx_pyrepl_web",
]
html_static_path = ["_static"]
pyrepl_doctest_blocks = "autodoc"
pyrepl_autodoc_packages = ":project:"
For a monorepo or non-default layout, point at the package root explicitly:
pyrepl_autodoc_packages = ":project:"
pyrepl_project_root = ".."
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_pyrepl_web-0.4.0.tar.gz.
File metadata
- Download URL: sphinx_pyrepl_web-0.4.0.tar.gz
- Upload date:
- Size: 300.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf2e64bd1746b53b45995a854720dc8e01c127293e35511458a5cdf081e6064
|
|
| MD5 |
04a19a78d08a07713940c8ecb50c3b00
|
|
| BLAKE2b-256 |
dd514da092e60595dc1eae12325171ae57bd1c85a960d520e2605d27d64b1e75
|
File details
Details for the file sphinx_pyrepl_web-0.4.0-py3-none-any.whl.
File metadata
- Download URL: sphinx_pyrepl_web-0.4.0-py3-none-any.whl
- Upload date:
- Size: 287.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
361958e3023485e811412ace166aa55f0dbdf7c7c35bccaaade439d2230c16e5
|
|
| MD5 |
a9c65b8acd5103539063fa62d6174843
|
|
| BLAKE2b-256 |
64dc78adb012306a375aae7f443fb98410b921a285e475b99d0a1eaa46653ef7
|