繁体   English   中英

防止 sphinx 重新启动每个文件的节编号

[英]Prevent sphinx from restarting section numbering every file

我的索引文件设置如下:

Doc Title
==============================

..toctree::
   :maxdepth: 3
   :numbered:
   :caption: Contents

   01_file1
   01.3_file2

如果内容是这样...

01_file1.txt:

Level 1 section title
--------------------------------------------

Level 2 section title
............................................

Another Level 2 section title
............................................

对于 01.3_file2.txt:

A third Level 2 section title
............................................

我希望这是因为 Sphinx 将所有内容都视为单个文档:

1. Level 1 section title
  1.1 Level 2 section title
  1.2 Another Level 2 section title
  1.3 A third Level 2 section title

但是我得到了这个:

1. Level 1 section title
  1.1 Level 2 section title
  1.2 Another Level 2 section title
2. A third Level 2 section title

我猜这是因为 Sphinx(或者可能是 reST/Markdown?)为每个新文本文件重新启动隐式标题级别。 有没有办法得到我真正想要的?

引用reST 文档...

不是强加固定数量和顺序的部分标题装饰样式,强制执行的顺序将是遇到的顺序。 遇到的第一个样式将是最外层的标题(如 HTML H1),第二个样式将是副标题,第三个将是副标题,依此类推。

父文件确定其包含的子文件的标题级别。 要达到预期的效果, 01.3_file2index删除01.3_file2 ,并在01_file1.txt中要包含它的位置放置一个.. include:: 01.3_file2


指数:

Doc Title
==============================

..toctree::
   :maxdepth: 3
   :numbered:
   :caption: Contents

   01_file1

01_file1.txt:

Level 1 section title
--------------------------------------------

Level 2 section title
............................................

Another Level 2 section title
............................................

.. include:: 01.3_file2.txt

01.3_file2.txt:

A third Level 2 section title
............................................

结果是:

1. Level 1 section title
  1.1 Level 2 section title
  1.2 Another Level 2 section title
  1.3 A third Level 2 section title

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM