python-sphinx - 将 Sphinx TOC 分成带有副标题的小节

标签 python-sphinx restructuredtext toctree

我有一个 Sphinx 主文档,其中包含如下子文档:

.. toctree::
    :maxdepth: 2
    :numbered:

    doc1
    doc2
    doc3
    doc4
    doc5
    doc6 

我想将目录分成几个部分或小节,以便它按照以下方式呈现:

Part 1: Title of Part 1
   <doc1 TOC>
   <doc2 TOC>
Part 2: Title of Part 2
   <doc3 TOC>
   <doc4 TOC>
Part 3: Title of Part 3 
   <doc5 TOC>
   <doc6 TOC>

我当前的方法是创建伪子文档,在其目录中列出实际文档,例如“part1.rst”将具有:

.. toctree::
    :maxdepth: 2
    :numbered:

    doc1
    doc2

然后在主文档中:

.. toctree::
    :maxdepth: 3
    :numbered:

    part1
    part2
    part3

这样做的问题是,当单击“part1”的链接时,您将进入一个没有实际内容的页面(“part1.rst”)。

还有其他方法吗?

或者,有没有办法禁止“part1.rst”条目生成页面链接?

最佳答案

一种选择是这样做:

.. toctree::
    :maxdepth: 2
    :numbered:

    doc1
    doc2
    doc3

Subheading
-----------

.. toctree::
    :maxdepth: 2
    :numbered:

    doc4
    doc5
    doc6 

关于python-sphinx - 将 Sphinx TOC 分成带有副标题的小节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22613739/

相关文章:

python - 关于 toctree 引用的警告

python - 使用 Sphinx 时,如何记录没有文档字符串的成员?

python - 如何使用 Sphinx 记录异常?

python - Sphinx 从自定义代码引用中删除代码格式

python-sphinx - 使用 self 在 sphinx 中创建带有 toctree 的站点地图似乎坏了?

python - toctree嵌套下拉

python-sphinx - 狮身人面像 : how to exclude imports in automodule?

python - 如何为 sphinx 文档保留装饰类的文档字符串?

html-lists - 如何在嵌套列表中使用自动枚举器 (reStructuredText)

python - 修改 automodule 指令下特定类的选项