A Sphinx extension to run python code in the documentation
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.
The full documentation can be found at here
.. exec-code::
print('This code will be executed')
generates
print('This code will be executed')
This code will be executed
- Add support for all options from code block
- Reworked how blocks and options are processed
- Add support for python 3.13
- Error when providing invalid options
- Updated CI and ruff fixes
- Fixed a bug when no code was shown/executed
- If the whole shown code block is indented the indention is removed
- 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
- Added config parameter to specify stdout encoding
- Only empty lines of the output get trimmed
- Fixed an issue where the line numbers for error messages were not correct
- Marked as safe for parallel reading
- Added option to run code from example files
- Added some more documentation and fixed some false path warnings
- Initial Release