spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
457 stars 130 forks source link

Notebook gallery without listing in table of contents? #647

Closed hakonanes closed 2 years ago

hakonanes commented 2 years ago

Can I create a notebook gallery, say, on the index page, without the notebooks listed in the table of contents? I assume no, since the nbgallery directive takes the same parameters as the toctree directive.

mgeier commented 2 years ago

Did you try the hidden flag?

See https://nbsphinx.readthedocs.io/en/0.8.8/subdir/toctree.html.

To also remove it from the sidebar, I had to set globaltoc_includehidden to False, even though that is supposed to be the default value (see https://www.sphinx-doc.org/en/master/usage/theming.html?highlight=globaltoc_includehidden%20#builtin-themes).

hakonanes commented 2 years ago

Thanks for the quick reply!

I should note that I'm including nbgallery directives in a index.rst file, and that I'm using the Furo theme.

I tried the hidden flag, as in

.. nbgallery::
    :hidden:

    my_notebook.ipynb

but the notebook is still listed in the sidebar. I didn't try nbsphinx-toctree since it's gallery notebooks I don't want listed in the sidebar, and it seems to me that nbsphinx-toctree is a regular toctree. Is globaltoc_includehidden set to False in the html_theme_options dictionary in conf.py?

While it would be nice if I could include a notebook gallery without the notebooks listed in the sidebar, it isn't crucial. I'm very happy with nbsphinx, and I believe I can get a good documentation even with all notebooks listed in the sidebar. Feel free to close this if you consider it an edge case or otherwise.

mgeier commented 2 years ago

I didn't try nbsphinx-toctree since it's gallery notebooks

I was providing the link only for the notebook metadata syntax (which mentions the "hidden" option). But since you use an .rst file, that's not relevant.

nbsphinx-toctree is a regular toctree

Yes, it is. But the notebook metadata options are the same between "toctree" and "gallery". In fact, a "gallery" is just a somewhat extended "toctree".

I'm using the Furo theme.

The option globaltoc_includehidden is a setting of Sphinx's basic theme, but maybe Furo doesn't support it. Maybe there is a separate option? You should check the Furo docs and if you don't find it, open an issue there.

hakonanes commented 2 years ago

Thanks for clarifying.

but maybe Furo doesn't support it.

I believe you're right, I cannot find the option in the current customization documentation. It seems like templating might be an option, but I don't have the time to look further at the moment.

mgeier commented 2 years ago

You can try it with another theme, e.g. with one of the built-in themes like classic.

If it works there, you can close this issue and create a new issue for the Furo theme.

I don't think that https://pradyunsg.me/furo/customisation/sidebar/#changing-sidebar-elements helps, since sidebar/navigation.html is a custom template provided by Furo. The one provided by Sphinx would be called globaltoc.html, but I guess that's not compatible with Furo?

See also https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars

hakonanes commented 2 years ago

The one provided by Sphinx would be called globaltoc.html, but I guess that's not compatible with Furo?

Yes, this template is explicitly not supported.

I'll try with a built-in theme, thanks.

mgeier commented 2 years ago

@hakonanes Did it work with a different theme?

hakonanes commented 2 years ago

Sorry for the late reply: I abandoned this approach and decided to stick to the current behaviour.

Please close this issue at your convenience, @mgeier.