Skip to content

Section navigation shows up even if it contains nothing #1662

@Charlie-XIAO

Description

@Charlie-XIAO
Contributor

This is introduced by #1632 I think. As seen in the screenshot, the section navigation is empty but still shows up.

image

Activity

djhoese

djhoese commented on Jan 24, 2024

@djhoese

I'm also seeing this. Originally my site consisted of two pages: an index and a "what's new". The index had a single hidden TOC with maxdepth 1. No customizations were done to the theme. No matter what I do I can't get rid of the left sidebar nor can I get it to display anything except "Section Navigation". Even if I add a third page nothing changes. I've tried unhiding the TOC. I've tried numbering the TOC. Nothing changes this from being just "Section Navigation".

drammock

drammock commented on Jan 24, 2024

@drammock
Collaborator

@djhoese and @Charlie-XIAO can you please provide

  • version of theme you're using
  • link to repo
  • link to built site
djhoese

djhoese commented on Jan 24, 2024

@djhoese

Of course, sorry. Here's the relevant packages:

$ mamba list sphinx
# packages in environment at /home/davidh/miniconda3/envs/geosphere_api_py311:
#
# Name                    Version                   Build  Channel
pydata-sphinx-theme       0.15.2             pyhd8ed1ab_0    conda-forge
sphinx                    7.2.6              pyhd8ed1ab_0    conda-forge
sphinxcontrib-applehelp   1.0.7              pyhd8ed1ab_0    conda-forge
sphinxcontrib-devhelp     1.0.5              pyhd8ed1ab_0    conda-forge
sphinxcontrib-htmlhelp    2.0.4              pyhd8ed1ab_0    conda-forge
sphinxcontrib-jsmath      1.0.1              pyhd8ed1ab_0    conda-forge
sphinxcontrib-qthelp      1.0.6              pyhd8ed1ab_0    conda-forge
sphinxcontrib-serializinghtml 1.1.9              pyhd8ed1ab_0    conda-forge

Docs source: https://gitlab.ssec.wisc.edu/cspp_geo/geosphere/geosphere-docs

Published site: https://geosphere.ssec.wisc.edu/docs/

Primary problem page (the only non-index page in my site): https://geosphere.ssec.wisc.edu/docs/whats-new.html

Edit: The source repository includes a Dockerfile that does all the dependency installs and building of the site.

Charlie-XIAO

Charlie-XIAO commented on Jan 25, 2024

@Charlie-XIAO
ContributorAuthor

@drammock Sorry for the late reply. The one I'm working on is the scikit-learn homepage, see scikit-learn/scikit-learn#28132. It is a bit too large, so I crafted a minimal reproducible example instead. The version is pydata-sphinx-theme==0.15.2.

Charlie-XIAO

Charlie-XIAO commented on Jan 28, 2024

@Charlie-XIAO
ContributorAuthor

I think the cause is here:

if kwargs.get("includehidden", False):
# if ancestor is found and `includehidden=True` we're guaranteed there's a
# TocTree to be shown, so don't suppress
return False

This assumption does not seem to be correct.

I opened #1682 to propose a fix. Hopefully it can be included in 0.15.3 otherwise I would have to pin 0.14.x in scikit-learn.

linked a pull request that will close this issue on Jan 28, 2024
djhoese

djhoese commented on Jan 28, 2024

@djhoese

That seems like valid logic to me unless I'm misunderstanding. In my case I have a parent TOC and the page I'm on could have a side bar, but the side bar is empty.

Charlie-XIAO

Charlie-XIAO commented on Jan 28, 2024

@Charlie-XIAO
ContributorAuthor

@djhoese Sorry I'm a bit confused now. From what I see you have on the index page

.. toctree::
   :maxdepth: 1
   :hidden:

   whats-new

and no toctree on the whats-new page, so I'm thinking there should indeed be nothing in the primary sidebar of the whats-new page, and the primary sidebar should not show up. Is that not what you mean? If so what do you expect to see in the primary sidebar?

In my case I have a parent TOC

But index is your root_doc so things (in your case whats-new) are showing in the top navbar I think, if I'm not misunderstanding how things should work.

drammock

drammock commented on Jan 28, 2024

@drammock
Collaborator

@djhoese using your docker image, I can make the sidebar disappear on your whats-new page by adding this to conf.py:

html_sidebars = {
    'whats-new': []
}

It is supposed to happen automatically when the sidebar elements are all empty, but for some buggy reason your whats-new page is ending up with a single empty TOC element:

<div class="bd-toc-item navbar-nav"></div>

If on the contrary you were expecting a TOC to actually appear there (below the "section navigation" heading) then there's a misunderstanding about the theme: your homepage is the site's root, and the whats-new page is the (only) first-level page; the left sidebar TOC by default would show any pages below that first-level page (of which there are none). The first-level pages only show up (by default) in the top navbar.

@Charlie-XIAO I haven't had time to look at your site yet, but will try to do so soon.

djhoese

djhoese commented on Jan 28, 2024

@djhoese

Sorry I'm a bit confused now

Is that not what you mean? If so what do you expect to see in the primary sidebar?

Honestly, I don't know. I think my thinking for my last comment was "if it is going to show the sidebar, then it must be considering the hidden TOC, so in that case there should be something shown". But yeah, if it isn't supposed to do anything with a hidden TOC as far as the sidebar goes then it makes sense that it is including the sidebar erroneously but the rest of the logic is correctly not finding anything to put in the sidebar (because it is hidden).

@drammock Thanks. All my googling kept leading to the navigation and sidebars page here:

https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/navigation.html

which doesn't mention the import html_sidebars configuration. I wouldn't have commented and looked through github issues if I would have just found this section from my searches:

https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/layout.html#primary-sidebar-left

Thanks everyone.

Charlie-XIAO

Charlie-XIAO commented on Jan 29, 2024

@Charlie-XIAO
ContributorAuthor

I haven't had time to look at your site yet, but will try to do so soon.

No hurries @drammock. Except from the site that linked, in #1682 I further provided a minimal reproducible site and corresponding tests, if those may help.

added
tag: componentIssues or improvements associated with a given component in the theme
on Feb 12, 2024
added a commit that references this issue on May 4, 2024
moved this from Todo to Discussion in Documentation improvementon May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tag: componentIssues or improvements associated with a given component in the theme

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @drammock@djhoese@trallard@Charlie-XIAO

      Issue actions

        Section navigation shows up even if it contains nothing · Issue #1662 · pydata/pydata-sphinx-theme