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.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_folders
toexec_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
File details
Details for the file sphinx_exec_code-0.13.tar.gz
.
File metadata
- Download URL: sphinx_exec_code-0.13.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c6b86404001cf875352de2707c72a3150fe608c08444637513f9dc01e424157 |
|
MD5 | a8142fd1bf379b44e38563bf2ffa2ea4 |
|
BLAKE2b-256 | 9d29894f739b26c39d5d3482d46ab75cda1741d32c4262f49ba49e4243ce0478 |
File details
Details for the file sphinx_exec_code-0.13-py3-none-any.whl
.
File metadata
- Download URL: sphinx_exec_code-0.13-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98cb1f49a816e39367172aee91a6d460067f6b2b1dae359eee3ed8e3394d213e |
|
MD5 | f8cc7375f55b9dda79f10483da53bed6 |
|
BLAKE2b-256 | cee92af2398995fce4fd8858e4bbd6fdea743499dc201c6782e22afaf7cd43c0 |