0

I have 2 rst files:

folder:
 |_file1.rst
 |_file2.rst

file1.rst:

.. toctree::
   :maxdepth: 3


Name1
========

Name2
========

file2.rst:

.. toctree::
   :maxdepth: 3


Name3
=========

Name4
=========

How to make so that in a tree to combine titles from 1 and 2 files. and navigation was the same in two files

bad_coder
  • 11,289
  • 20
  • 44
  • 72
markus
  • 9
  • 1

1 Answers1

0

My understanding of your question is that you currently have two files with their own "local" toctrees (which doesn't do anything incidentally) and want a third document providing a global toctree. If that's correct, then you just need to create that file, give it a toctree and specify which documents to link to:

.. toctree::
   :maxdepth: 2

   file1
   file2

Note that Sphinx cares about the level of the titles, not really the document themselves, so because all your titles are "toplevel" your global toctree will be

  • Name1
  • Name2
  • Name3
  • Name4

not e.g.

  • file1
    • Name1
    • Name2
  • file2
    • Name3
    • Name4

I don't know which one you want, but if it's the latter you need to add a single top-level "document name" title to your document (customarily a title both overlined and underlined, the overlining effort is not huge since it's only a single title / line which is marked that way).

Masklinn
  • 34,759
  • 3
  • 38
  • 57
  • I have two files with rst extension. can i somehow merge them toctree. for example, that both files in the navigation were name1 name2 name3 name4. – markus Mar 22 '19 at 09:05
  • I really don't understand your situation / use case, it's not clear what the inputs and outputs you expect are so providing help is challenging. If you have two files with the exact same titles and you create a toctree linking both, you'll get a sequence of all the titles e.g. with the code above and the files you're now telling me about, you'll have 8 toctree entries name1, name2, name3, name4, name1, name2, name3, name4; the first 4 linking to file1 and the last 4 linking to file2. – Masklinn Mar 22 '19 at 09:17