Divide Sphinx TOC into subsections with subheadings

人盡茶涼 提交于 2019-12-01 21:36:56

问题


I have a Sphinx master document which includes child documents as follows:

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

    doc1
    doc2
    doc3
    doc4
    doc5
    doc6 

I would like to divide the TOC into parts or subsections, so that it renders along the lines of:

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>

My current approach is to create pseudo-child documents, that list the actual documents in their TOC, for example, "part1.rst" would have:

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

    doc1
    doc2

and then in the master document:

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

    part1
    part2
    part3

The problem with this is that when clicking the link for "part1", you are taken to a page with no real content ("part1.rst").

Is there any other approach?

Alternatively, is there a way to suppress the entry for "part1.rst" from generating a page link?


回答1:


One option is to do it like this:

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

    doc1
    doc2
    doc3

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

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

    doc4
    doc5
    doc6 


来源:https://stackoverflow.com/questions/22613739/divide-sphinx-toc-into-subsections-with-subheadings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!