0

I'm trying to create a single entry on the main toctree with three nested entries that each link to a page (because our main TOC is already quite long). The structure is like this:

- Layers
    + Using Layers
    + Layer Arguments
    + Layers List

Layers is layers.rst and Using Layers is a heading in layers.rst. I created two more headings in layers.rst for Layer Arguments and Layers List because I want them to be on the same level. I created a toctree under the Layers Arguments heading, and a second one under Layers List so when you click on them it brings you to the TOC under each heading.

When you click Layer Arguments/Layers List I want it to go to the top of layer_args.rst/layers_list.rst, not to the heading in layers.rst. Is it possible to create a nested toctree that links to files in the sidebar?

Edit: Example

index.rst

<some headings and text>

.. toctree::
   :maxdepth: 2
   :caption: Layers

   layers

layers.rst

.. _using-layers:

------------------------------------------------
Using Layers
------------------------------------------------

<text>

------------------------------------------------
Layer Arguments
------------------------------------------------

.. toctree::
   :maxdepth: 2

   Layer Arguments <layers/layer_args>

------------------------------------------------
Layers List
------------------------------------------------

.. toctree::
   :maxdepth: 2

   I/O Layers <layers/io_layers>
   Operator Layers <layers/operator_layers>
   Transform Layers <layers/transform_layers>
   .
   .
   .

layers/io_layers.rst

layers/operator_layers.rst

layers/transform_layers.rst

Katie
  • 21
  • 1
  • 7
  • 2
    Please provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Steve Piercy Jan 27 '22 at 07:12
  • I have added an example – Katie Jan 27 '22 at 19:40
  • Sorry, I meant an example repo that I can clone. I just don't have the desire to set up a sample project from scratch. – Steve Piercy Jan 28 '22 at 11:55
  • Oh, sure- if you clone my branch you can just 'make html' in the docs directory and it should work. `git clone https://github.com/graham63/lbann.git document_layers` – Katie Jan 28 '22 at 21:20
  • Which branch? I don't see any directory `docs/layers/`. – Steve Piercy Jan 29 '22 at 06:20
  • It's the `document_layers` branch. If you use the `git clone https://github.com/graham63/lbann.git document_layers` command it will be on the correct branch – Katie Jan 31 '22 at 03:45

1 Answers1

0

I would move the file layers.rst to layers/index.rst, and adjust paths accordingly. Thus your directory structure and navigation structure align with one another.

docs/index.rst

.. toctree::
   :maxdepth: 2
   :caption: LBANN Layers

   layers/index

docs/layers/index.rst

------------------------------------------------
Layer Arguments
------------------------------------------------

.. toctree::
   :maxdepth: 2

   Layer Arguments <layer_args>

------------------------------------------------
LBANN Layers List
------------------------------------------------

.. toctree::
   :maxdepth: 2

   I/O Layers <io_layers>
   Operator Layers <operator_layers>
   Transform Layers <transform_layers>
Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
  • 1
    Unless I'm missing something this doesn't seem to affect the table of contents at all. It would have the same effect as just moving `layers.rst` into the layers directory. Clicking on the entries "Layer Arguments" and "Layers List" still just bring the user to the bottom of "layers/index.rst" instead of to the top of a landing page like when the user clicks on "Using layers." It seems clunky, but I don't think the three sections warrant space on the main TOC. – Katie Feb 02 '22 at 16:20
  • 1
    Did you try it out and compare? Make sure to do a `make clean html` to purge the cache of navigation elements. – Steve Piercy Feb 03 '22 at 08:49
  • Yeah- since the toctrees for `layer args` and `layer list` are under headings in `layers/index.rst` the link on the side bar just leads to the heading in `layers/index.rst` instead of to the pages for `layer_args` and maybe another jumping off page for `layers_list`. It's not so bad for `layers_list` because it expands the list of layers in the sidebar but it's confusing for `layer_args` that it doesn't jump to the correct page. – Katie Feb 07 '22 at 02:30