Execute code blocks in Sphinx and display the output
Project description
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.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
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_exec_code-0.16.tar.gz.
File metadata
- Download URL: sphinx_exec_code-0.16.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51458982dc7a152802dfac9786af656c7fe35206203452d9f6322cac45534b32
|
|
| MD5 |
791958be0fc11870403f4ed8ec2e3215
|
|
| BLAKE2b-256 |
450da94b374aef31918bf88af058c10ebf556a199818e30a8fa0df6f952eabc7
|
Provenance
The following attestation bundles were made for sphinx_exec_code-0.16.tar.gz:
Publisher:
publish-pypi.yml on spacemanspiff2007/sphinx-exec-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_exec_code-0.16.tar.gz -
Subject digest:
51458982dc7a152802dfac9786af656c7fe35206203452d9f6322cac45534b32 - Sigstore transparency entry: 190722795
- Sigstore integration time:
-
Permalink:
spacemanspiff2007/sphinx-exec-code@02e3d9514c6eca085b437b21de2a7eadce497124 -
Branch / Tag:
refs/tags/v0.16 - Owner: https://github.com/spacemanspiff2007
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@02e3d9514c6eca085b437b21de2a7eadce497124 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sphinx_exec_code-0.16-py3-none-any.whl.
File metadata
- Download URL: sphinx_exec_code-0.16-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5cd4f8d2d4b929d522e14ccf30ac569f8864a9c241e91cb93fc8324abdd9c52
|
|
| MD5 |
bbff9966143fd2caf52003f30ef88e27
|
|
| BLAKE2b-256 |
8c5ca9d7d2407124512be434044e4504b2e62a7a1a0e5863ca384b37241c0ddf
|
Provenance
The following attestation bundles were made for sphinx_exec_code-0.16-py3-none-any.whl:
Publisher:
publish-pypi.yml on spacemanspiff2007/sphinx-exec-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_exec_code-0.16-py3-none-any.whl -
Subject digest:
b5cd4f8d2d4b929d522e14ccf30ac569f8864a9c241e91cb93fc8324abdd9c52 - Sigstore transparency entry: 190722836
- Sigstore integration time:
-
Permalink:
spacemanspiff2007/sphinx-exec-code@02e3d9514c6eca085b437b21de2a7eadce497124 -
Branch / Tag:
refs/tags/v0.16 - Owner: https://github.com/spacemanspiff2007
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@02e3d9514c6eca085b437b21de2a7eadce497124 -
Trigger Event:
release
-
Statement type: