Toctree强制将单独的文档显示为小节

时间:2019-07-12 08:42:29

标签: documentation python-sphinx restructuredtext

背景

我正在为Python模块创建文档。该文档包含一些通用页面,例如 contributing,building 。现有的toctree指令如下所示:

==================== 
Module Documentation 
==================== 

.. toctree::                        
   :caption: Table of Contents      
   :maxdepth: 2                     
   :caption: Contents:              

   build                            
   contributing                     
   testing                          



Indices and tables                  
==================                  

* :ref:`genindex`                   
* :ref:`modindex`                   
* :ref:`search`   

文件结构

文件结构如下:

/where/I/keep/my/stuff/PythonModule/docs/source/
|-- build.rst
|-- conf.py
|-- contributing.rst
|-- index.rst
|-- running.rst
|-- _static
|-- _templates
`-- testing.rst

问题

我不知道如何构造toctree,所以我可以实现以下目标:

  • 为了便于编辑,我想以以下方式创建单独的文件来描述模块的功能:

      /where/I/keep/my/stuff/PythonModule/docs/source/
      |-- build.rst
      |-- conf.py
      |-- contributing.rst
      |-- Functions.rst
      |-- Function-A.rst
      |-- Function-B.rst
      |-- Function-C.rst
      |-- Function-n.rst
      |-- index.rst
      |-- running.rst
      |-- _static
      |-- _templates
      `-- testing.rst
    
    • 我希望toctree创建以下索引

            - Contributing
            - Building
            - Testing
            - Key Functions
                - Function A
                - Function B
                - Function C
                - Function n
      

摘要

我想实现两件事:

  1. 为了便于编辑,我想将功能文档文件保留为单独的文件
  2. 出于可读性考虑,我想将这些文件显示为主要“章节” 的小节,我们将其称为 Functions

注释

  • 如果有更明智的方法,例如,将每个功能的文档保存在/source/functions中,就可以了。我要避免的是创建一个名为.rst的大型Functions文档,并制作子标题来描述每个单独的功能。

0 个答案:

没有答案
相关问题