Sphinx Doc - Include Jupyter Notebook

Keywords: Sphinx Doc, Jupyter Notebook, Jupyter Lab, JupyterNotebook, JupyterLab

Summary

介绍如何在 Sphinx Doc 文档中嵌入 Jupyter Notebook.

  1. Install nbsphinx.

  2. Add extension to your sphinx doc conf.py file.

extensions = [
    "nbsphinx",
]
  1. Include notebook in RestructuredText.

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   notebooks/Example 1
  1. Make sure you add IPython to your requirements-doc.txt file, otherwise the Sphinx Doc cannot show Syntax Highlight in Code Block.

Reference: