Skip to content

Add ability to write nested index.rst #855

@tacaswell

Description

@tacaswell

Currently sphinx-gallery writes output that looks like

- top_level
   - index.rst
   - subdir
      - example.rst
      - example2.rst
      - <lots of other non-rst files>
   - subdir2
      - example1.rst
      - example2.rst
      - <other stuff>

and in the top level index.rst there is a sub-section pre sub-directory and for each example there is a block that looks like

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="See ~matplotlib.axes.Axes.plot.">

.. only:: html

 .. figure:: /plot_types/basic/images/thumb/sphx_glr_plot_thumb.png
     :alt: plot(X, Y)

     :ref:`sphx_glr_plot_types_basic_plot.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /plot_types/basic/plot

which puts in a hidden 1 element toc to include the underlying .rst files and then the logic to link to them. However this plays very badly with extremely large gallerys and the pydata-sphinx theme and gives you side bars like https://matplotlib.org/devdocs/gallery/index.html which are just way too long.

I propose that inside of each of the sub-directories and index.rst also gets written that has the same html content and a

.. toctree::
   :hidden:
   
   example1
   example2

and at the top level instead of writing many single-entry TOCs there is one

.. toctree::
   :hidden:
   
   subdir/index
   subdir2/index

I believe that this will correctly communicate to sphinx what the intended structure is and then will reflect that nesting in the left bar of the pydata theme.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions