AZD*_*AZD 4 restructuredtext python-sphinx
我使用了出色的Sphinx工具来创建一些文档,并且试图通过将同一部分的章节分成单独的文件来使代码库保持模块化形式。(有关“章节”和“部分”的定义,请参见此处。)
我尝试使用两个文件来执行此操作test1.rst:
######
Part 1
######
*********
Chapter 1
*********
Section 1
=========
Test Content 1.
Run Code Online (Sandbox Code Playgroud)
和test2.rst:
*********
Chapter 2
*********
Section 2
=========
Test Content 2.
Run Code Online (Sandbox Code Playgroud)
它们index.rst像这样包含在其中:
.. toctree::
:maxdepth: 2
test1
test2
Run Code Online (Sandbox Code Playgroud)
但是,在构建时,第2章没有嵌套在第1部分中。这是为什么?是否有任何方法无需创建脚本即可将它们附加到单个文件中,就像下面的示例一样?
例:
######
Part 1
######
*********
Chapter 1
*********
Section 1
=========
Test Content 1.
*********
Chapter 2
*********
Section 2
=========
Test Content 2.
Run Code Online (Sandbox Code Playgroud)
似乎该include指令是您要寻找的。包含文件的内容将在指令的位置进行解析并包含在内。
test1.rst:
######
Part 1
######
*********
Chapter 1
*********
Section 1
=========
Test Content 1.
.. include:: test2.rst
Run Code Online (Sandbox Code Playgroud)