|
1 | | -{# Overrides pydata-sphinx-theme's sidebar-nav-bs to render the global |
2 | | - document toctree on every page (including the landing page). The |
3 | | - stock template's generate_toctree_html starts at the current |
4 | | - section, which leaves the root index with no sidebar at all. Using |
5 | | - the toctree() Jinja global instead always shows the top-level |
6 | | - structure, with the current section expanded and highlighted. #} |
| 1 | +{# Renders the global document toctree on every page (including the |
| 2 | + landing page) with pydata-sphinx-theme's collapsible chevrons. |
| 3 | + |
| 4 | + The stock sidebar-nav-bs.html starts at the current section and is |
| 5 | + stripped from the sidebar list by suppress_sidebar_toctree() on the |
| 6 | + root page (no parent section). Using generate_toctree_html with |
| 7 | + startdepth=0 renders the whole tree from root with the bootstrap |
| 8 | + classes the theme's JS uses for expand/collapse toggles. Naming the |
| 9 | + template "sidebar-globaltoc" sidesteps the suppress filter, which |
| 10 | + matches on "sidebar-nav-bs.html" specifically. #} |
7 | 11 | <nav class="bd-docs-nav bd-links" aria-label="{{ _('Section Navigation') }}"> |
8 | 12 | <p class="bd-links__title" role="heading" aria-level="1">{{ _("Section Navigation") }}</p> |
9 | 13 | <div class="bd-toc-item navbar-nav"> |
10 | | - {{ toctree(maxdepth=theme_navigation_depth | int, |
11 | | - collapse=theme_collapse_navigation | tobool, |
12 | | - includehidden=True, |
13 | | - titles_only=True) }} |
| 14 | + {# collapse=False so nested <ul>s render into the DOM for every |
| 15 | + branch; the theme's JS then adds the expand/collapse chevrons |
| 16 | + on top. show_nav_level=1 keeps deeper levels collapsed by |
| 17 | + default so the landing-page sidebar isn't a wall of links. #} |
| 18 | + {{- generate_toctree_html( |
| 19 | + "sidebar", |
| 20 | + startdepth=0, |
| 21 | + show_nav_level=theme_show_nav_level | int, |
| 22 | + maxdepth=theme_navigation_depth | int, |
| 23 | + collapse=False, |
| 24 | + includehidden=True, |
| 25 | + titles_only=True |
| 26 | + ) |
| 27 | + -}} |
14 | 28 | </div> |
15 | 29 | </nav> |
0 commit comments