插件

由于许多项目在其文档中需要特殊特性,Sphinx允许在构建过程中添加“扩展”,每个扩展几乎可以修改文档处理的任何方面。

本章介绍与Sphinx捆绑的插件。有关编写自己的扩展的API文档,请参阅:ref:dev extensions

内置插件

这些插件是内置的,可以通过:confval:`extensions`配置值中的相应条目激活:

第三方插件

You can find several extensions contributed by users in the sphinx-contrib organization. If you wish to include your extension in this organization, simply follow the instructions provided in the github-administration project. This is optional and there are several extensions hosted elsewhere. The awesome-sphinxdoc and sphinx-extensions projects are both curated lists of Sphinx packages, and many packages use the Framework :: Sphinx :: Extension and Framework :: Sphinx :: Theme trove classifiers for Sphinx extensions and themes, respectively.

你自己的插件放在哪里?

项目的本地扩展应该放在项目的目录结构中。设置Python的模块搜索路径``搜索路径``,这样斯芬克斯才能找到他们。例如,如果您的分机``食品``位于项目根目录的“exts”子目录中,放入:文件:conf.py:

import sys, os

sys.path.append(os.path.abspath('exts'))

extensions = ['foo']

您也可以在任何其他地方安装插件``搜索路径``,例如在“站点包”目录中。