jupyterlite-sphinx 简介

目录

jupyterlite-sphinx 简介#

Sphinx 扩展,为在文档中嵌入 JupyterLite 提供实用工具。

jupyterlite-sphinx 将 JupyterLite 的强大功能带入您的 Sphinx 文档。它在您的文档中实现了一个完整的 JupyterLite 部署,并提供了易于使用该部署的一些实用工具。

安装#

您可以使用 pip 安装 jupyterlite-sphinx

pip install jupyterlite-sphinx

jupyterlite-sphinx 也可以在 conda-forge 上找到。您可以使用 condamamba 安装它:

# 使用 conda
conda install -c conda-forge jupyterlite-sphinx

# 使用 mamba
mamba install -c conda-forge jupyterlite-sphinx

然后,您需要将 jupyterlite-sphinx 扩展添加到您的 Sphinx 文档的 conf.py 文件中:

extensions = [
    'jupyterlite_sphinx',
    # And other sphinx extensions
    # ...
]

JupyterLite 应该会自动显示在您构建的在线文档中。要在本地预览它,您可以导航到构建目录(例如 _build/html),并使用 python -m http.server 来提供站点。

备注

默认情况下,jupyterlite-sphinx 不会安装 Python 内核。 如果您希望在文档中使用 Python 内核,可以使用 pip 安装 jupyterlite-pyodide-kerneljupyterlite-xeus

# 安装基于 Pyodide 的 Python 内核
pip install jupyterlite-pyodide-kernel

# 加载基于 Xeus 的内核
pip install jupyterlite-xeus