【问题标题】:How to generate index.rst alone or generate everything excluding conf.py by sphinx-apidocs?如何单独生成 index.rst 或通过 sphinx-apidocs 生成除 conf.py 之外的所有内容?
【发布时间】:2014-02-18 01:03:03
【问题描述】:

我了解以下为所有模块生成 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.paths。如果我修改“very_good”文件夹中的 python 代码,我应该运行不带“-F”的 sphinx-apidoc 命令,因此 conf.py 被保留。但是,如果我直接在very_good 下添加一个新模块,没有“-F”选项,index.rst 不会更新,这意味着我的新模块不会在文档中。我想解决方案是要么只生成 index.rst 文件,要么使用“-F”选项而不覆盖 conf.py。有办法吗?

【问题讨论】:

    标签: python python-sphinx sphinx-apidoc


    【解决方案1】:

    这是我现在正在经历的事情。没有找到信息来实现如此常见的事情真是令人沮丧。

    我的方法是使用自定义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%
    

    【讨论】:

      猜你喜欢
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-24
      • 1970-01-01
      • 2016-07-14
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      相关资源
      最近更新 更多