在Sphinx中分割源文档(即管理文件层次结构)

发布于 2025-01-08 04:19:17 字数 542 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼波传意 2025-01-15 04:19:17

我正在回答我自己的问题(羞耻!),因为我终于明白我做错了什么。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文