sphinx-exec-code
A Sphinx extension to run python code in the documentation
About
Sphinx-exec-code allows execution of any python code during the documentation build. It's also possible to display the output of the code execution.
With this extension it's easy to ensure that the provided code samples are always working. Additionally, it's possible to show the output of the documented code.
Each code snippet runs in a fresh interpreter so changes to not leak between executions.
Documentation
The full documentation can be found at here
Quick Example
.. exec-code::
print('This code will be executed')
generates
print('This code will be executed')
This code will be executed
Changelog
0.18 (2026-03-18)
- Fixed warning
0.17 (2026-03-18)
- Dropped support for Python 3.8
- Added some type hints and updated dependencies
0.16 (2025-04-01)
- Fixed an issue where the
hideandhide_outputoptions were not working correctly
0.15 (2024-12-10)
- Removed confusing log output
0.14 (2024-11-15)
- Add support for all options from code block
- Reworked how blocks and options are processed
0.13 (2024-10-15)
- Add support for python 3.13
0.12 (2024-01-09)
- Error when providing invalid options
0.11 (2024-01-09)
- Updated CI and ruff fixes
0.10 (2023-02-13)
- Fixed a bug when no code was shown/executed
0.9 (2023-02-08)
- If the whole shown code block is indented the indention is removed
0.8 (2022-07-18)
- Renamed
exec_code_folderstoexec_code_source_folders - Changed type of parameter to specify stdout to a flag
- Changed default for config parameter that sets encoding
- Dropped support for Python 3.7
0.7 (2022-07-15)
- Added config parameter to specify stdout encoding
- Only empty lines of the output get trimmed
0.6 (2022-04-04)
- Fixed an issue where the line numbers for error messages were not correct
0.5 (2022-03-10)
- Marked as safe for parallel reading
0.4 (2022-03-09)
- Added option to run code from example files
0.3 (2021-09-24)
- Added some more documentation and fixed some false path warnings
0.2 (2021-09-21)
- Initial Release
Metadata
Release files for sphinx-exec-code 0.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinx_exec_code-0.18.tar.gz | 16.7 kB | With provenance | Details for sphinx_exec_code-0.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinx_exec_code-0.18-py3-none-any.whl | Python 3 | none | any | Details for sphinx_exec_code-0.18-py3-none-any.whl |
Total release size: 34.2 kB
Release files / sphinx_exec_code-0.18.tar.gz
| Download URL | sphinx_exec_code-0.18.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f254c44dfe91a6e1337675535b098296a7bafbcc0d0feb5759f93fb720e8546f
|
|
BLAKE2b-256 checksum How to use checksums |
ce7f2705ea70eb6d7b9a72f6f035fa85160d0eb53876653f5ed697708eb186d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.
Transparency logRelease files / sphinx_exec_code-0.18-py3-none-any.whl
| Download URL | sphinx_exec_code-0.18-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
257c5847adab86f971c9ec20849df84aec4c8ee05aca787915efaac930586656
|
|
BLAKE2b-256 checksum How to use checksums |
b62c6e0aa56de08a48324eae2f0fda32d4ffc769dd72fafc62da55c1f7f14510
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.
Transparency logSecurity for sphinx-exec-code 0.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sphinx_exec_code-0.18.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.