A Sphinx extension for embedding pyrepl-web Python REPLs in documentation.
Project description
sphinx-pyrepl-web
Sphinx extension to embed pyrepl-web in documentation.
Install
pip install sphinx-pyrepl-web
For development:
pip install -e ".[test,docs]"
Usage
Add the extension to the target project's conf.py:
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
Most options drive pyrepl-web's attributes, with a few exceptions unique to this extension:
| Option | Description | pyrepl-web attr? |
|---|---|---|
:theme: |
Color theme (catppuccin-mocha, catppuccin-latte) |
✅ |
:packages: |
Comma-separated PyPI packages to preload | ✅ |
:repl-title: |
Title in the REPL header | ✅ |
:src: |
Path to a Python startup script | ✅ |
:replay: |
Replay :src: with interactive prompts instead of silent load |
✅ |
:silent: |
Keep :src: silent even when combined with a directive body |
❌ |
:strip-prompts: |
Strip >>> / ... prefixes from directive body |
❌ |
:no-header: |
Hide the header bar | ✅ |
:no-buttons: |
Hide copy/clear buttons | ✅ |
:readonly: |
Disable input | ✅ |
:no-banner: |
Hide the Python version banner | ✅ |
Directive body content (inline Python in the .. py-repl:: block) is also extension-only: it is written to _static/pyrepl/ at build time and emitted as replay-src.
Optional Sphinx config:
pyrepl_js = "../pyrepl.js" # default; path to the pyrepl-web loader script
Updating pyrepl-web
Since chrizzFTD/pyrepl-web is a fork, this sphinx extension vendors the JavaScript assets for easier distribution. To update them, run:
python scripts/vendor_repl.py
The grill branch is used by default. Use the branch argument to specify a different one:
python scripts/vendor_repl.py --branch cursor/repl-startup-replay-2e3f
Project details
Release history Release notifications | RSS feed
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.1.1.tar.gz.
File metadata
- Download URL: sphinx_pyrepl_web-0.1.1.tar.gz
- Upload date:
- Size: 283.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b71998e5dc8ec050c7517dd69793d5d5d6a9db56cc539056af364c782db378
|
|
| MD5 |
cae64cea1b8d5f8c92479b193a06bab6
|
|
| BLAKE2b-256 |
d8509b92fcdb104cbc868db7769578781016cb5244ade64833caa0b2c753562d
|
File details
Details for the file sphinx_pyrepl_web-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sphinx_pyrepl_web-0.1.1-py3-none-any.whl
- Upload date:
- Size: 282.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4be6f59ea856b6605a4a7f29aaf3ab994078d6896acb5aaf09768af428af60be
|
|
| MD5 |
0c858ca38b4cf1e4d1302e6f547b3de3
|
|
| BLAKE2b-256 |
6ffcad6b0af98692efa7a99b352e8673cec628b7ba6def4fda3d39f0175eaf66
|