Jupyter Sphinx Extension#
Jupyter-sphinx is a Sphinx extension that executes embedded code in a Jupyter kernel, and embeds outputs of that code in the document. It has support for rich output such as images, Latex math and even javascript widgets, and it allows to enable thebelab for live code execution with minimal effort.
.. jupyter-execute::
print("Hello world!")
print("Hello world!")
Hello world!
See also
Other extensions exist to display output of IPyhton cells in a Sphinx documentation. If you want to execute entire notebooks you can consider using nbsphinx or myst-nb. For in-page live execution consider using sphinx-thebe or jupyterlite-sphinx. For users that don’t need to rely on a jupyter kernel the lightweigth IPython sphinx directive can be used but remember it will only be able to display text outputs.