Skip to content

Commit 52c0095

Browse files
timsaucerclaude
andcommitted
docs: render expandable chevrons in sidebar nav
Switch the sidebar toctree call from toctree() to generate_toctree_html with collapse=False, so nested <ul>s render into the DOM for every branch. The pydata-sphinx-theme JS then wraps them in <details> with fa-chevron-down toggles, matching the datafusion-comet sidebar where each section with children can be expanded inline. show_nav_level=1 keeps deeper levels collapsed on first load. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3c8b530 commit 52c0095

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
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. #}
711
<nav class="bd-docs-nav bd-links" aria-label="{{ _('Section Navigation') }}">
812
<p class="bd-links__title" role="heading" aria-level="1">{{ _("Section Navigation") }}</p>
913
<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+
-}}
1428
</div>
1529
</nav>

0 commit comments

Comments
 (0)