Jupyter Sphinx Extensions

0.5.3 · active · verified Fri Apr 17

Jupyter Sphinx Extensions is a Sphinx extension that enables embedding Jupyter Notebook content directly into Sphinx documentation. It allows executing notebook cells, displaying outputs (text, images, interactive widgets), and including entire notebooks. The current version is 0.5.3, with releases typically occurring on an 'as needed' basis, often annually or bi-annually for minor updates.

Common errors

Warnings

Install

Quickstart

To use jupyter-sphinx, add 'jupyter_sphinx' to the `extensions` list in your Sphinx `conf.py` file. Then, use directives like `jupyter-execute` (for inline code blocks) or `nbtosf-execute` (for external .ipynb files) in your reStructuredText or MyST Markdown files. Remember to include `jupyter-output` if you want to display the execution results.

# conf.py
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'jupyter_sphinx',
]

# Optional: Configure caching for faster builds
jupyter_sphinx_execute_options = {
    'kernel': 'python3', # Specify kernel if not default
    'timeout': 60, # Timeout for execution
    'cache': '.jupyter_cache' # Enable caching
}

# index.rst or your_doc.md
# .. jupyter-execute::
#
#     import pandas as pd
#     df = pd.DataFrame({'A': [1,2], 'B': [3,4]})
#     print(df)
#
# .. jupyter-output::
#
# For external notebooks:
# .. nbtosf-execute:: path/to/your_notebook.ipynb

view raw JSON →