Python sphinx Sphinx/RST:是否包含另一个RST文件而不将其添加到TOC?
我正在改进一些技术文档(Sphinx),并希望在多个位置包含RST文件的内容;但是,在这样做时,RST文件被多次添加到TOC中。如何将文件包含在我想要的位置,但只引用TOC中的部分一次 以下是index.rst文件的外观:Python sphinx Sphinx/RST:是否包含另一个RST文件而不将其添加到TOC?,python-sphinx,restructuredtext,sections,toctree,Python Sphinx,Restructuredtext,Sections,Toctree,我正在改进一些技术文档(Sphinx),并希望在多个位置包含RST文件的内容;但是,在这样做时,RST文件被多次添加到TOC中。如何将文件包含在我想要的位置,但只引用TOC中的部分一次 以下是index.rst文件的外观: Documentation ================= .. toctree:: :maxdepth: 4 ../path/to/releasenotes.rst ../path/to/general_api_usage.rst main_c
Documentation
=================
.. toctree::
:maxdepth: 4
../path/to/releasenotes.rst
../path/to/general_api_usage.rst
main_content.rst
.. _section-2:
This is Section 2
********************
.. include: section4.rst
Some other Section 2 content.
接下来,这里是main_content.rst:
============
Main Content
============
These docs reference:
- :ref:`section-1`.
- :ref:`section-2`.
- :ref:`section-3`.
- :ref:`section-4`.
.. include:: section1.rst
.. include:: section2.rst
.. include:: section3.rst
.. include:: section4.rst
“第4节”为参考表;例如,我想把它包括在“第2节”中,但也要像附录一样放在文档的底部
下面是第2.rst节的内容:
Documentation
=================
.. toctree::
:maxdepth: 4
../path/to/releasenotes.rst
../path/to/general_api_usage.rst
main_content.rst
.. _section-2:
This is Section 2
********************
.. include: section4.rst
Some other Section 2 content.
最后,第4.rst节可能是什么样子的:
.. _section-4:
This is Section 4
********************
+------------------+-------------------------+
| Heading | Heading 2 |
+==================+=========================+
| This is what I | want to reference |
+------------------+-------------------------+
| in other rst | files. |
+------------------+-------------------------+
当我这样做时,我的目录中包含了两次“第4节”。有什么见解吗?谢谢 多亏@sinoroc的建议,我想出了一个解决方案: 我从第4.rst节中删除了以下内容,只保留了表格:
.. _section-4:
This is Section 4
********************
我将其添加到新文件appendix.rst的顶部,并添加了对section4.rst的引用:
.. _section-4:
This is Section 4
********************
.. include:: section4.rst
然后,我修改了我的主要内容rst,以参考附录rst,而不是第4.rst节
我的主要学习点:TOC反映了引用文件中的标题。是否可以从文档
section4.rst
中删除章节标题,并在需要时将其移动到包含的文档中?或者标题是否比示例中显示的更多?谢谢@sinoroc。这真的很有帮助。多亏了你的建议,我完成了我希望做的事情。你能把这个标记为答案,让其他人看到它已经被回答了吗?谢谢