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

Specifying tocdepth doesn't influence the sidebar TOC depth on that page #6033

Closed
jorisvandenbossche opened this issue Feb 7, 2019 · 5 comments

Comments

@jorisvandenbossche
Copy link
Contributor

jorisvandenbossche commented Feb 7, 2019

Describe the bug

I am trying to use :tocdepth: to specify the depth of the toctree in the sidebar on a specific page. However, whatever depth I specify, it doesn't make the toctree on that page deeper.

Example set-up of my docs is here: https://github.com/jorisvandenbossche/sphinx-test/tree/master/test-toctree
So basically, I have a subdirectory with pages. And on those individual pages, I want that the sidebar toc also shows additional toc levels for the sections on that page.
On the main index.rst page, I included the toc with a :maxdepth: 2, because on the body of that page, I want to show only a limited table of contents of the site.

To Reproduce

Steps to reproduce the behavior:

$ git clone https://github.com/jorisvandenbossche/sphinx-test
$ cd sphinx-test/test-toctree
$ make html
$ # open _build/html/user_guide/page1.html

Expected behavior

I would expect that a :tocdepth: on a certain page would overrule the :maxdepth: of a toctree in the sidebar.

However, it might be that my expectation is wrong. If so, it is not fully clear to me what the purpose is of :tocdepth:, and the documentation saying "The maximum depth for a table of contents of this file." (docs) is also not that very clarifying.

But, going from some old threads on sphinx-users (eg https://groups.google.com/forum/#!searchin/sphinx-users/tocdepth|sort:date/sphinx-users/SqY5O0jM1JA/i74RIRoIBwAJ or https://groups.google.com/forum/#!searchin/sphinx-users/tocdepth|sort:date/sphinx-users/TzfuzcDo7Hs/RUOiOtIGI04J), I understand that :tocdepth: should be able to control the depth of the sidebar TOC.

Environment info

  • OS: Linux (Ubuntu)
  • Python version: 3.5.5
  • Sphinx version: 1.8.1
@ghost
Copy link

ghost commented Mar 30, 2019

@jorisvandenbossche That seems to be an issue with the theme: sphinx-doc/alabaster#89

Do you have the same issue with other themes?

When testing this with sphinx_rtd_theme I found that setting tocdepth seems to influence the sidebar depth no matter what page I'm on, which seems like a bug in of itself. But I think the particular issue you're dealing with is an issue with alabaster or whatever theme you're using.

@segevfiner
Copy link
Contributor

On my own project, this is bugging out differently. Setting tocdepth seems to cause it to be set to 1, or something like that, for the sidebar. But my docs are only two pages so who knows what buggy behavior this really exhibits on my end.

Sphinx 2.1.2
Python 3.7.4

@danielhuppmann
Copy link

Seems that using https://pypi.org/project/sphinxcontrib-fulltoc/ also resolves this issue.

@tk0miya
Copy link
Member

tk0miya commented Nov 2, 2019

Confirmed. Indeed :tocdepth: is not applied to HTML output.

In my short investigation, it modifies the depth of local toctree. But alabaster uses global toctree instead. So :tocdepth: feature is disabled on the theme. For example, you can see the its behavior when you switches the theme of your project to classic.

I agree with you that our document is not kind. So I'll update it to mention about above behavior later.

@tk0miya tk0miya added this to the 2.3.0 milestone Nov 2, 2019
@tk0miya tk0miya modified the milestones: 2.3.0, 2.4.0 Dec 8, 2019
tk0miya added a commit that referenced this issue Feb 8, 2020
docs: Add a restriction note about tocdepth (refs: #6033)
@tk0miya
Copy link
Member

tk0miya commented Feb 8, 2020

I just added a note to our document. Closing.
Thanks,

@tk0miya tk0miya closed this as completed Feb 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants