问题
Structure
The following structure of the project:
index.rstMyProject ========= Contents: .. toctree:: group1group1.rstGroup1 ------ Subgroup1 ========= Subgroup1 contents Subgroup2 ========= Subgroup2 contents
Rendered to (after clicking on Group1 -> Subgroup2):
As you can see it opens the Group1 page and linked to Subgroup2 section.
Want
I want to have the same on the left side (Group1 openned and Subgroup2 choosed) but on the right side I want to see only Subgroup2 page (page without Subgroup1 content).
I.e. have file group1/subgroup1.rst:
Subgroup2
=========
Subgroup2 contents
Rendered to:
How it can be achieved? This is a simple example with the depth 2, what about depth 3-4?
回答1:
You need to have a file per page of content. Sphinx doesn't break files into multiple pages.
What works for me is creating toctree directives that reference files containing sub-toctree directives. I like to create the sub-groups in directories, but you could do this within one directory.
index.rst:
MyProject
=========
Contents:
.. toctree::
group1/index
group1/index.rst:
Group1
======
.. toctree::
subgroup1
subgroup2
group1/subgroup1.rst:
Subgroup1
=========
Subgroup1 contents
group1/subgroup2.rst:
Subgroup2
=========
Subgroup2 contents
来源:https://stackoverflow.com/questions/34249244/how-to-make-toctree-link-refer-to-the-separate-file-like-it-refers-to-the-subsec