Python 如何将扩展永久添加到Sphinx conf.py模板?

Python 如何将扩展永久添加到Sphinx conf.py模板?,python,python-sphinx,Python,Python Sphinx,我通常在每个Sphinx文档项目中使用某些扩展名,例如sphinxcontrib.bibtex,这意味着我需要为每个项目将扩展名添加到conf.py文件中 # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.

我通常在每个
Sphinx
文档项目中使用某些扩展名,例如
sphinxcontrib.bibtex
,这意味着我需要为每个项目将扩展名添加到
conf.py
文件中

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest',
'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage',
'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode',
'sphinxcontrib.bibtex']

是否有一个简单的方法,可以在
conf.py
中默认包含这些设置?

您可以创建一个包含默认设置的模块,然后将它们导入到配置文件中

但是,除非您单独处理项目,否则最好始终在项目中包含完整配置,以便其他处理项目的人员知道他们正在使用相同的设置构建项目


另一种选择是创建一个模板配置文件,其中包含可用于新项目的设置。

对于通常使用相同conf.py的项目,我通常将其符号链接到多个项目,并将其保存在git下,以便跟踪更改。然后所有项目都将从一个conf.py更新。不过,这通常适用于PDF版本,具有general、output.PDF名称等。