sphinx-toggleprompt
Add a python prompt toggle to each code cell.
What it is and what it does
sphinx-toggleprompt is a Sphinx extension that enhances Python code examples in documentation by adding an interactive button to toggle the >>> prompts and output lines. This allows readers to view the same code in two forms: with prompts and output (as it appears in a Python REPL), or as clean, copyable code without prompts. The extension depends only on sphinx and integrates directly into your Sphinx conf.py configuration.
It's designed for documentation projects that include Python code examples and want to give readers control over how they view those examples. The extension works alongside other Sphinx tools like sphinx-copybutton to provide a complete code-viewing experience. Since it's copied from the official Python docs theme, it follows established patterns for documentation code presentation.
Use it for:
- Tutorial documentation where showing both REPL interactions and clean code snippets adds clarity.
- API documentation with Python examples that benefit from toggling between interactive and copyable formats.
- Educational materials that teach Python by showing both the prompt and the resulting output.
- Mixed documentation where some readers want to copy code directly and others want to see execution context.
- Projects using sphinx-copybutton that want complementary prompt-hiding functionality.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds a button to Python code blocks in Sphinx documentation that toggles >>> prompts and removes output lines for cleaner code display.
Yes, if you maintain Sphinx documentation with Python code examples and want readers to toggle between REPL-style and clean code views. The low install friction, permissive license, and lack of known vulnerabilities make it a safe addition. The aging maintenance status (553 days since release) is a minor concern, but the repository remains active and the extension is simple enough to be stable. Install it if prompt toggling improves your documentation's usability.
Install
sphinx-toggleprompt on PyPI
pip
pip install sphinx-togglepromptuv
uv add sphinx-togglepromptpoetry
poetry add sphinx-togglepromptInstalling sphinx-toggleprompt
Before you install
Low friction installation with a single runtime dependency on sphinx. The package is aging (553 days since last release) but the repository remains active with a recent commit in September 2025, suggesting maintenance continues despite infrequent releases.
License in practice
MIT License permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install sphinx-toggleprompt
In conf.py:
extensions = [
'sphinx_toggleprompt',
]
Requires Python 3.9 or later and an existing Sphinx documentation project.
Verify before relying
- Whether the toggle button works reliably across all Sphinx themes and versions.
- Compatibility with recent Sphinx releases and any breaking changes in the Sphinx extension API.
- Performance impact on documentation builds with many code blocks.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — sphinx |
| Maintenance | aging — 553 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 192,450/month — #9,865 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sphinx_toggleprompt-0.6.0-py3-none-any.whl
Tags
More Sphinx packages
Parses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
sphinxcontrib-serializinghtmlA Sphinx extension that outputs documentation…
permissive · top 1,000 on PyPI
alabasterAlabaster is a clean, responsive Sphinx theme…
permissive · top 1,000 on PyPI
sphinxcontrib-htmlhelpA Sphinx extension that generates HTML help…
permissive · top 1,000 on PyPI
sphinxcontrib-qthelpA Sphinx extension that converts documentation…
permissive · top 1,000 on PyPI
sphinx-copybuttonA Sphinx extension that adds a copy button to…
permissive · top 5,000 on PyPI
sphinx-togglebuttonA Sphinx extension that adds collapsible toggle…
permissive · top 15,000 on PyPI
sphinx-promptSphinx Prompt is a Sphinx extension that…
permissive · top 5,000 on PyPI
sphinx-thebeAdds interactive, executable code blocks to…
unclear · top 15,000 on PyPI
sphinx-rtd-dark-modeAdds a toggleable dark mode interface to Sphinx…
permissive · top 15,000 on PyPI
sphinx-panelsA Sphinx extension that adds directives for…
permissive · top 15,000 on PyPI
sphinx-bootstrap-themeA Sphinx theme that applies Bootstrap CSS and…
permissive · top 15,000 on PyPI
jupyter-sphinxJupyter Sphinx Extensions runs code embedded in…
unclear · top 15,000 on PyPI
furoFuro is a clean, responsive Sphinx theme for…
permissive · top 5,000 on PyPI
sphinxcontrib-runcmdA Sphinx extension that executes arbitrary…
permissive · top 15,000 on PyPI