numpydoc icon indicating copy to clipboard operation
numpydoc copied to clipboard

Enable expanding ToC in numpydoc doc

Open zmoon opened this issue 4 years ago • 4 comments

https://github.com/numpy/numpydoc/blob/b4f21263e3b227f0c49ca65d99c56751186c072f/doc/conf.py#L140-L142

seems to disable the expansion of the ToC headings. I don't know if this is a bug or a feature but it is unfortunate since it makes the improvement of #320 a bit less useful.

Edit: looks like the fix is to replace it by

html_sidebars = {
    "**": ["sidebar-nav-bs.html"],
}

Originally posted by @zmoon in https://github.com/numpy/numpydoc/issues/320#issuecomment-824127548

zmoon avatar Apr 21 '21 15:04 zmoon

The mentioned setting is about the left sidebar, while the TOC is actually in the right sidebar.

So there is another reason that this is not working ..

From looking at the latest readthedocs https://numpydoc.readthedocs.io/en/latest/format.html, it seems the javascript is not loading correctly. And the "highlight section while scrolling page" feature is done with javascript.

jorisvandenbossche avatar Apr 25 '21 13:04 jorisvandenbossche

Independently, you could also be interested in https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/configuring.html#show-more-levels-of-the-in-page-toc-by-default, which would show this second level items in the TOC by default.

jorisvandenbossche avatar Apr 25 '21 13:04 jorisvandenbossche

@jorisvandenbossche I can assure you that the fix I mentioned above does work though (I did a local build), and it does ~~not~~ affect the left sidebar (still nonexistent, but makes it wider), ~~only the right~~.

Edit: I inspected the differences in the generated HTML. The same JS is being loaded in both cases. The main difference is that this gets added, which like you said is a left sidebar thing. But somehow that makes the ToC expansion work.

Edit2: Seems like maybe the issue is that before activating the ToC expansion stuff, in the JS it looks for id bd-docs-nav, which doesn't exist if sidebar-nav-bs.html wasn't included.

zmoon avatar Apr 25 '21 13:04 zmoon

@jorisvandenbossche have you had a chance to look at my previous comment?

zmoon avatar May 09 '21 20:05 zmoon