如何自定义sphinx-quickstart的配置
当我运行 sphinx-quickstart
时,
看到那些选项让我觉得很烦。
我能不能有一个默认的配置?这样就不用一个一个去勾选那些选项了?
Please indicate if you want to use one of the following Sphinx extensions:
> autodoc: automatically insert docstrings from modules (y/n) [n]:
> doctest: automatically test code snippets in doctest blocks (y/n) [n]:
> intersphinx: link between Sphinx documentation of different projects (y/n) [n]:
> todo: write "todo" entries that can be shown or hidden on build (y/n) [n]:
> coverage: checks for documentation coverage (y/n) [n]:
> pngmath: include math, rendered as PNG images (y/n) [n]:
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]:
> ifconfig: conditional inclusion of content based on config values (y/n) [n]:
> viewcode: include links to the source code of documented Python objects (y/n) [n]:
3 个回答
0
简单来说,你需要考虑的是自己写一个脚本,这样可以把所有东西都按照你想要的方式整理好,而且在这个过程中不会问你任何问题。sphinx-quickstart
是一个通用工具,可以让你进行一定程度的自定义。它主要是为那些对项目结构不太熟悉的初学者设计的,如果你知道该把所有东西放在哪里,其实可以不使用 sphinx-quickstart
。在我参与的项目中,我通常会为大多数操作(比如初始化、构建、部署等)创建自己的 Python 或 Bash 脚本。希望这对你有帮助。
1
我使用一个自定义脚本(一个自定义的快速启动)来传递默认配置,以生成函数:
# -*- coding: utf-8 -*-
import re
import sys
from sphinx.quickstart import generate, do_prompt
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
d= {
'path': '.',
'sep': True,
'dot': '_',
'author': 'C. Brun',
'version': '1.0',
'release': '1.0',
'suffix': '.rst',
'master': 'index',
'epub': False,
'ext_autodoc': False,
'ext_doctest': False,
'ext_intersphinx': False,
'ext_todo': False,
'ext_coverage': False,
'ext_pngmath': False,
'ext_mathiax': False,
'ext_ifconfig': True,
'ext_todo': True,
'ext_viewcode': False,
'makefile': True,
'batchfile': False,
}
if 'project' not in d:
print '''
Nom du projet
'''
do_prompt(d, 'project', 'Project Name')
generate(d)