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

The sidebar does not expand when the ToC depth is limited #7171

Closed
petsuter opened this issue Feb 17, 2020 · 8 comments
Closed

The sidebar does not expand when the ToC depth is limited #7171

petsuter opened this issue Feb 17, 2020 · 8 comments
Labels
html theme type:proposal a feature suggestion
Milestone

Comments

@petsuter
Copy link
Contributor

Describe the bug
The sidebar does not expand when the ToC depth is limited.

To Reproduce
Steps to reproduce the behavior:

  • sphinx-quickstart and select all defaults (Alabaster theme)
  • Change / create these files:
  • index.rst:
 .. toctree::
   :maxdepth: 1
   
   sub/index
  • sub/index.rst:
Sub
===

.. toctree::
   :maxdepth: 1
   
   topic
  • sub/topic.rst:
Subtopic
========

test
$ make html
  • Open _build/html/index and see everything looks fine. The sidebar on the left shows "Sub". Also the ToC in the middle shows "Sub". All looks OK.
  • Click "Sub" and see ToC in the middle shows "Subtopic" as expected. But the problem is the sidebar still only shows "Sub". It did not expand and does not show "Subtopic"!

test-sphinx.zip

Expected behavior
The sidebar should expand, even if :maxdepth: is used.

Environment info

  • OS: Windows 10
  • Python version: 3.7.1
  • Sphinx version: 2.4.1
  • Sphinx extensions: None
@petsuter
Copy link
Contributor Author

This is still a problem in Sphinx 3.1.1

@mgeier
Copy link
Contributor

mgeier commented Jun 18, 2020

So you are suggesting that the :maxdepth: setting should simply be ignored w.r.t. the sidebar/globaltoc?

I don't think that's a good idea.

If this were changed, people would come and complain that they specified :maxdepth: but it doesn't work in the sidebar.

Some people will complain either way, but I think the current behavior is more consistent.

@petsuter
Copy link
Contributor Author

petsuter commented Jun 18, 2020

I can not speak for everyone. But to me it is very weird that these two things are coupled together. Why does the local maxdepth affect the global sidebar? Maybe I'm misunderstanding something or am not aware of other options. I expect the sidebar to expand to show the location of the current subpage in the toc, while the ToC in the middle shows just the next level of sub-pages.

I would have guessed that there are maybe some html_theme_options to control the sidebar. But I tried all combinations I could think of for any option I could find and none worked.

I don't suggest changing existing behavior if others think it is working as intended. To me at the moment it seems broken, but I'm happy to change my files and use some other setting that gives the desired result.

@mgeier
Copy link
Contributor

mgeier commented Jun 30, 2020

But to me it is very weird that these two things are coupled together.

I agree.
But this is a very different issue (which you can open if you want!).

I would have guessed that there are maybe some html_theme_options to control the sidebar.

This depends on the theme, some theme have options like this.

I've recently added the options globaltoc_collapse and globaltoc_includehidden, but we decided not to add globaltoc_maxdepth before anybody requests it: #7443 (comment)

You might probably be interested in this?

But note that this would be a global setting for the whole TOC. So this might still not be fine-grained enough for your needs?

@petsuter
Copy link
Contributor Author

petsuter commented Jul 1, 2020

Thanks for the pointers.

I now tried changing globaltoc_collapse in the example above, unfortunately using Sphinx v3.1.1 there seems to be no visible change in the output. Or I'm missing something.. Could you maybe give an example?

Do I understand correctly that the desired behavior I described above would be achieved (once the option is implemented) by this configuration:

html_theme_options = {
    'globaltoc_collapse': True,
    'globaltoc_maxdepth': None,
}

As suggested I opened issue #7902 to request it to be implemented.

@mgeier
Copy link
Contributor

mgeier commented Jul 1, 2020

Yes, that's how you would use it.

But IIRC, True is already the default for "collapse", so this won't change anything.

And I guess the "unlimited" value for "maxdepth" would be -1, I'm not sure whether None will work (it would probably select the default behavior?).

See https://www.sphinx-doc.org/en/master/templating.html#toctree.

@petsuter
Copy link
Contributor Author

petsuter commented Jul 1, 2020

@tk0miya
Copy link
Member

tk0miya commented Jul 7, 2020

I just post #7925 to add globaltoc_maxdepth :-)

@tk0miya tk0miya added html theme type:proposal a feature suggestion and removed type:bug labels Jul 7, 2020
@tk0miya tk0miya added this to the 3.2.0 milestone Jul 7, 2020
@tk0miya tk0miya closed this as completed Jul 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
html theme type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

3 participants