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

TOC in navigation side bar is generated incorrectly for depth > 3 #12926

Closed
khanxmetu opened this issue Sep 28, 2024 · 3 comments
Closed

TOC in navigation side bar is generated incorrectly for depth > 3 #12926

khanxmetu opened this issue Sep 28, 2024 · 3 comments
Labels

Comments

@khanxmetu
Copy link
Contributor

Describe the bug

The global table of contents in the navigation side bar isn’t generated correctly when the depth of the current document is more than 3.

How to Reproduce

$ cat index.rst 
index
------

.. toctree::

    a

$ cat a.rst 
a
--

.. toctree::

    b

$ cat b.rst 
b
--

.. toctree::

    c

$ cat c.rst 
c
--

.. toctree::

    d
$ cat d.rst 
d
--

$ sphinx-build -m html . _build

Output
Table of contents in navigation sidebar on page d.html only shows link to page a

Expected Output
All the ancestors till the current page: a, b, c, d were expected to be shown.

Environment Information

Platform:              linux; (Linux-6.6.31+rpt-rpi-v8-aarch64-with-glibc2.36)
Python version:        3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0])
Python implementation: CPython
Sphinx version:        8.1.0+/1b08b66d1
Docutils version:      0.20.1
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

No response

Additional context

No response

@khanxmetu
Copy link
Contributor Author

Not really sure if this was an intended behavior in global toctree generation to avoid generating siblings at every level of depth in order to reduce build times.

@mgeier
Copy link
Contributor

mgeier commented Sep 28, 2024

This likely depends on the HTML theme you are using. With the default alabaster theme I'm seeing links to a, b, c and d.

What theme are you using?

@khanxmetu
Copy link
Contributor Author

khanxmetu commented Sep 28, 2024

This likely depends on the HTML theme you are using. With the default alabaster theme I'm seeing links to a, b, c and d.

What theme are you using?

I'm using alabaster too. Sorry for the wrong assumption, the issue
isn't related to tree depth.

I had a hard time reproducing as well and I figured that the problem occurred due to adding a toctree entry of some document and building the second time while keeping previous build's files.

Here is the reproducer:

$ cat index.rst
index
-----

.. toctree::
    a

$ cat b.rst 
b
--

.. toctree::


$ cat c.rst 
c
--


$ sphinx-build -b html . _build/

$ # add doc c into b's toctree
$ vi b.rst
$ cat b.rst 
b
--

.. toctree::
    c

$ # build again
$ sphinx-build -b html . _build/

$ cat _build/c.html | grep 'href="a.html"'
<li class="toctree-l1"><a class="reference internal" href="a.html">a</a></li>
$ cat _build/c.html | grep 'href="b.html"'
$ cat _build/c.html | grep 'href="#"'

c.html should contain links to a,b and self, however it only contains a link to a.html

@khanxmetu khanxmetu closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants