将Sphinx TOC划分为子标题的子部分

时间:2014-03-24 15:31:02

标签: python-sphinx restructuredtext

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

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

    doc1
    doc2
    doc3
    doc4
    doc5
    doc6 

我想将TOC划分为部分或子部分,以便它们呈现:

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>

我目前的做法是创建伪子文档,列出其TOC中的实际文档,例如&#34; part1.rst&#34;会有:

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

    doc1
    doc2

然后在主文档中:

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

    part1
    part2
    part3

问题在于,当点击&#34; part1&#34;的链接时,您将进入没有真实内容的页面(&#34; part1.rst&#34;)。

还有其他办法吗?

或者,有没有办法抑制&#34; part1.rst&#34;从生成页面链接?

1 个答案:

答案 0 :(得分:3)

一种选择是这样做:

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

    doc1
    doc2
    doc3

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

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

    doc4
    doc5
    doc6 
相关问题