Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何单独生成index.rst或通过sphinx apidocs生成conf.py以外的所有内容?_Python_Python Sphinx_Sphinx Apidoc - Fatal编程技术网

Python 如何单独生成index.rst或通过sphinx apidocs生成conf.py以外的所有内容?

Python 如何单独生成index.rst或通过sphinx apidocs生成conf.py以外的所有内容?,python,python-sphinx,sphinx-apidoc,Python,Python Sphinx,Sphinx Apidoc,我理解以下内容为所有模块生成rst,不包括index.rst sphinx-apidoc -f -o very_good_docs/ very_good 下面将生成所有内容,包括index.rst、conf.py、Makefile等 sphinx-apidoc -F -f -o very_good_docs/ very_good 问题是sphinx apidoc没有生成正确的conf.py,因此我必须始终手动修改conf.py以包含正确的sys.path。如果我在“very_good”文件夹

我理解以下内容为所有模块生成rst,不包括index.rst

sphinx-apidoc -f -o very_good_docs/ very_good
下面将生成所有内容,包括index.rst、conf.py、Makefile等

sphinx-apidoc -F -f -o very_good_docs/ very_good

问题是sphinx apidoc没有生成正确的conf.py,因此我必须始终手动修改conf.py以包含正确的sys.path。如果我在“very_good”文件夹中修改python代码,我应该在不使用“-F”的情况下运行sphinx apidoc命令,因此conf.py将被保留。但是,如果我直接在very_good下添加新模块,index.rst在没有“-F”选项的情况下不会更新,这意味着我的新模块将不在文档中。我猜解决方案是要么有人只生成index.rst文件,要么使用“-F”选项而不重写conf.py。有办法吗?

这是我现在正在经历的事情。找不到信息来实现如此普遍的目标真是令人沮丧

我的方法是使用自定义的
config.py
,并始终使用
-F
选项执行
sphinx build
。这样,即使创建了新的(且无用的)
config.py
,我的
config.py
也不会被覆盖

要指定自定义
config.py
,应使用文档中所述的
-c
选项:

-c path

Don’t look for the conf.py in the source directory, but use the given configuration directory instead. Note that various other files and paths given by configuration values are expected to be relative to the configuration directory, so they will have to be present at this location too.

New in version 0.3.
该命令将如下所示:

sphinx-build -b html -c %sphinxConfigDir% %sourceCode% %buildDir%