sphinx-book-theme icon indicating copy to clipboard operation
sphinx-book-theme copied to clipboard

globaltoc_maxdepth

Open jamesdbrock opened this issue 2 years ago • 4 comments

Describe the bug

context

Sphinx                        5.3.0
sphinx-book-theme             1.0.1

conf.py:

html_theme = 'sphinx_book_theme'
html_theme_options = {
    "globaltoc_maxdepth": 1,
}

expectation

The left sidebar table of contents should be limited to a depth of 1.

bug

The left sidebar table of contents has a depth of 3.

image

problem

Is the sphinx-book-theme supposed to respect "globaltoc_maxdepth"? Does anyone know how to limit the depth of the left sidebar table of contents?

Reproduce the bug

List your environment

I'm not running jupyter-book, I'm running sphinx-build.

$ sphinx-build --version
sphinx-build 5.3.0

jamesdbrock avatar Sep 14 '23 04:09 jamesdbrock

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Sep 14 '23 04:09 welcome[bot]

It seems like maybe the left sidebar table of contents maxdepth is hard-coded as 4?

https://github.com/executablebooks/sphinx-book-theme/blob/a9794b73cec766e01bee35a96f7d44e22851f278/src/sphinx_book_theme/theme/sphinx_book_theme/components/sbt-sidebar-nav.html#L18

jamesdbrock avatar Sep 14 '23 04:09 jamesdbrock

Maybe I can customize the left sidebar with these instructions. https://github.com/executablebooks/sphinx-book-theme/blob/master/docs/sections/sidebar-primary.md

jamesdbrock avatar Sep 14 '23 04:09 jamesdbrock

Ok I got this working. I copyed the file sbt-sidebar-nav.html to a local file sphinx_book_theme_override/sbt-sidebar-nav-override.html and changed it to read maxdepth=2,.

Then in conf.py:

templates_path = ['_templates', './sphinx_book_theme_override']

html_sidebars = {
    "**": ["navbar-logo.html", "sbt-sidebar-nav-override.html"]
}

But it would be nice if the sphinx_book_theme respected globaltoc_maxdepth. So I'll leave this issue open.

jamesdbrock avatar Sep 14 '23 05:09 jamesdbrock