Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section navigation shows up even if it contains nothing #1662

Open
Charlie-XIAO opened this issue Jan 19, 2024 · 10 comments · May be fixed by #1682
Open

Section navigation shows up even if it contains nothing #1662

Charlie-XIAO opened this issue Jan 19, 2024 · 10 comments · May be fixed by #1682
Labels
tag: component Issues or improvements associated with a given component in the theme

Comments

@Charlie-XIAO
Copy link
Contributor

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

image

@djhoese
Copy link

djhoese commented Jan 24, 2024

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
Copy link
Collaborator

@djhoese and @Charlie-XIAO can you please provide

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

@djhoese
Copy link

djhoese commented Jan 24, 2024

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
Copy link
Contributor Author

@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
Copy link
Contributor Author

Charlie-XIAO commented Jan 28, 2024

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.

@Charlie-XIAO Charlie-XIAO linked a pull request Jan 28, 2024 that will close this issue
@djhoese
Copy link

djhoese commented Jan 28, 2024

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
Copy link
Contributor Author

Charlie-XIAO commented Jan 28, 2024

@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
Copy link
Collaborator

drammock commented Jan 28, 2024

@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
Copy link

djhoese commented Jan 28, 2024

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: component Issues or improvements associated with a given component in the theme
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants