在Sphinx中分割源文档(即管理文件层次结构)
在 Sphinx 中分割源文档的正确方法(如果有)是什么?
我有一个很大的文件,我们称之为file1.rst
,它的结构是这样的:
Section 1
*********
Subsection 1
============
Subsection 2
============
Subsection 3
============
每个小节都很长,源文件已经变得难以管理。我想将每个小节放在不同的源文件中。
我尝试使用 include
指令:
Section 1
*********
.. include:: subsection1.rst
.. include:: subsection2.rst
.. include:: subsection3.rst
但它发出警告,指出 subsection1.rst 中的标签在section1.rst 中重复(不是真的,标签仅在子文档中)。
或者,是否有可能更改 TOC 指令中的层次结构?
What is the correct way, if any, of splitting a source document in Sphinx?
I have a large file, let's call it file1.rst
, the structure of which is like this:
Section 1
*********
Subsection 1
============
Subsection 2
============
Subsection 3
============
Each subsection is very long, and the source file has become unmanageable. I would like to put each subsection in a different source file.
I tried with the include
directive:
Section 1
*********
.. include:: subsection1.rst
.. include:: subsection2.rst
.. include:: subsection3.rst
But it's issuing warnings that labels in subsection1.rst are duplicated in section1.rst (not true, the label is only in the sub-document).
Alternatively, is there any possibility to change the hierarchy in the TOC directive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在回答我自己的问题(羞耻!),因为我终于明白我做错了什么。
TOC、目录指令可以多次使用。这将产生我正在寻找的层次结构。
我希望这对那些像我一样认为只能有一个 TOC 的人有所帮助。
I'm answering my own question (shame!) because I finally understood what I was getting wrong.
The TOC, table of contents directive can be used multiple times. This will result in the hierarchical structure that I was looking for.
I hope this can be of help for those who, like me, thought that there can be one TOC only.