I'm improving some technical docs (Sphinx) and would like to include the contents of an RST file in multiple places; however, in doing so, that RST file is being added to the TOC multiple times. How can I include the file where I want but only reference the section in the TOC once?
Here's what the index.rst file looks like:
Documentation
=================
.. toctree::
:maxdepth: 4
../path/to/releasenotes.rst
../path/to/general_api_usage.rst
main_content.rst
Next, here's 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
"Section 4" is a reference table; I'd like to include it in "Section 2", for example, but also keep it at the bottom of the docs like an appendix.
Here's what section2.rst looks like:
.. _section-2:
This is Section 2
********************
.. include: section4.rst
Some other Section 2 content.
And finally, what section4.rst might look like:
.. _section-4:
This is Section 4
********************
+------------------+-------------------------+
| Heading | Heading 2 |
+==================+=========================+
| This is what I | want to reference |
+------------------+-------------------------+
| in other rst | files. |
+------------------+-------------------------+
When I do this, my table of contents includes "Section 4" twice. Any insights? Thanks!