【问题标题】:Headings of different files do not match不同文件的标题不匹配
【发布时间】:2014-06-11 16:57:37
【问题描述】:

我在 Sphinx 中有一个非常基本的设置。目录如下:

.. toctree::
   :maxdepth: 3

   one
   two

文件一和二是这样的:

一个.rst

####
Part
####

*******
Chapter
*******

Section
=======

两个.rst:

***************
Another Chapter
***************

Another Section
===============

两个文件的格式相同,我希望得到以下结构

Part
|- Chapter
  |- Section
|- Another Chapter
  |- Another Section

然而,斯芬克斯给了我

Part
|- Chapter
  |- Section
Another Chapter
|- Another Section

我拆分文件的原因是它们相当大,我想保持它们很小,以便我可以轻松地编辑它们。如何在不同的文件中获得相同的标题样式(具有相同的上划线/下划线字符)?

【问题讨论】:

    标签: include python-sphinx restructuredtext sections toctree


    【解决方案1】:

    我相信你想要的是include directive。例如在 1.rst 你会放

    ####
    Part
    #### 
    
    *******
    Chapter
    *******  
    
    Section
    =======
    
    .. include:: 2.rst
    .. include:: 3.rst
    .. include:: 4.rst
    

    这将包括 2.rst 以及您想要在当前文件中的许多其他文件,并继续当前的结构布局。此外,将您的 index.rst 更改为 1.rst。

    .. toctree::
       :maxdepth: 3
    
       1.rst
       part2.rst
       part3.rst
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2013-10-10
      相关资源
      最近更新 更多