From d359930d014a08d1768f5a013182aec0ca9f44e3 Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Fri, 5 Jan 2024 17:31:59 -0600 Subject: [PATCH 1/5] maybe fix missing sidebar? --- src/pydata_sphinx_theme/toctree.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pydata_sphinx_theme/toctree.py b/src/pydata_sphinx_theme/toctree.py index f8c46d924..300dfe627 100644 --- a/src/pydata_sphinx_theme/toctree.py +++ b/src/pydata_sphinx_theme/toctree.py @@ -35,9 +35,12 @@ def add_inline_math(node: Node) -> str: def get_unrendered_local_toctree( app: Sphinx, pagename: str, startdepth: int, collapse: bool = True, **kwargs ): - """.""" - if "includehidden" not in kwargs: - kwargs["includehidden"] = False + """Get the "local" (starting at `startdepth`) TOC tree containing the current page. + + This is similar to `context["toctree"](**kwargs)` in sphinx templating, + but using the startdepth-local instead of global TOC tree. + """ + kwargs.setdefault("includehidden", True) if kwargs.get("maxdepth") == "": kwargs.pop("maxdepth") @@ -457,12 +460,10 @@ def get_local_toctree_for( doctree = self.env.tocs[indexname].deepcopy() toctrees = [] - if "includehidden" not in kwargs: - kwargs["includehidden"] = True + kwargs.setdefault("includehidden", True) if "maxdepth" not in kwargs or not kwargs["maxdepth"]: kwargs["maxdepth"] = 0 - else: - kwargs["maxdepth"] = int(kwargs["maxdepth"]) + kwargs["maxdepth"] = int(kwargs["maxdepth"]) kwargs["collapse"] = collapse # TODO: use `doctree.findall(addnodes.toctree)` once docutils min version >=0.18.1 From bd8f789b5926a8a5ac1b66bc1ef00867ddef069b Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Mon, 8 Jan 2024 11:24:52 -0600 Subject: [PATCH 2/5] simplify --- .../theme/pydata_sphinx_theme/layout.html | 2 +- src/pydata_sphinx_theme/toctree.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html index 13ea08afd..48c8532db 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html @@ -82,7 +82,7 @@
{# Primary sidebar #} {# If we have no sidebar TOC, pop the TOC component from the sidebar list #} - {% if get_sidebar_toctree_length(show_nav_level=theme_show_nav_level|int) == 0 %} + {% if check_for_sidebar_toctree(show_nav_level=theme_show_nav_level|int) %} {% set sidebars = sidebars | reject("in", "sidebar-nav-bs.html") | list %} {% endif %}