跳转到主要内容

Sphinx扩展,可从任何Python脚本集中构建HTML示例画廊。

项目描述

PyPI Conda-forge Zenodo DOI Azure CI status CircleCI status Code coverage

这是一个 Sphinx 扩展,可以从任何一组Python脚本中构建HTML示例画廊。请查看文档了解如何使用它及其他信息...

A demo of a gallery generated by Sphinx-Gallery

快速入门

Sphinx-Gallery可用于从.py文件生成示例画廊,用于库,以及展示特定Python包、模块或类示例的独立网页。

让我们从一个简单的示例开始,或者查看

文档以了解如何使用它及其他信息...

通过pip安装

您可以通过以下方式使用pip直接安装:

$ pip install sphinx-gallery

将示例添加到您的文档中

让我们假设一个简单的场景,您有一个Python包,其目录结构如下

├── doc
│   ├── conf.py
│   ├── index.rst
|   ├── make.bat
│   └── Makefile
├── my_python_module
│   ├── __init__.py
│   └── mod.py
└── examples
    ├── plot_example.py
    └── README.txt (or .rst)

通过在您的doc/conf.py中添加以下内容启用Sphinx-Gallery

extensions = [
    ...
    'sphinx_gallery.gen_gallery',
]

# path to the examples scripts
sphinx_gallery_conf = {
    'examples_dirs': '../examples',   # path to your example scripts
    'gallery_dirs': 'auto_examples',  # path to where to save gallery generated output
}

最后,像往常一样编译您的文档。Sphinx-Gallery将生成reST文件,添加执行输出,并将它们保存到auto_examples/中。将auto_examples/index.rst的链接添加到您的文档中,以包含画廊。

贡献

您可以从我们的GitHub仓库获取最新的开发源代码。您需要在系统中安装setuptools才能安装Sphinx-Gallery。例如,您可以这样做:

$ git clone https://github.com/sphinx-gallery/sphinx-gallery
$ cd sphinx-gallery
$ conda install graphviz  # if using conda, you can get graphviz this way
$ pip install -e .[dev]

运行以下命令以检查您是否已准备好:

$ pytest sphinx_gallery

如何引用

如果您想引用Sphinx-Gallery,可以使用我们的Zenodo存档

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

sphinx_gallery-0.17.1.tar.gz (464.0 kB 查看哈希值)

上传时间 源代码

构建分发

sphinx_gallery-0.17.1-py3-none-any.whl (446.2 kB 查看哈希值)

上传时间 Python 3

支持