sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.55k stars 2.12k forks source link

Add options to the nature theme #11313

Open ynikitenko opened 1 year ago

ynikitenko commented 1 year ago

Is your feature request related to a problem? Please describe. I have a problem with the toc sidebar. Since some Sphinx changes, it includes too much noise!

Describe the solution you'd like There is an option globaltoc_maxdepth in the basic theme, which references html sidebars (though some people argue that global toc is not about sidebars). Why couldn't it be added to the nature theme as well? Why don't add other options to the "nature" theme? Maybe also to other themes, but I'm using that one.

Describe alternatives you've considered I tried to set proper toc nesting via template, but failed. It doesn't allow maxdepth. I tried to use toctree(maxdepth=2), but toctree() produces no output.

toc directive should be as general as toctree() (after it works). Hardcoding ul/li is just bad! We are using jinja templates, we don't need people write this html code for us (especially when we can't customize that). Do we have to write filters to clean it up? Maybe someone could give an example of such filter? Thank you.

Additional context This is ugly! https://github.com/sphinx-doc/sphinx/issues/11000 I wonder whether there is much attention to details when adding/changing features in Sphinx. https://github.com/sphinx-doc/sphinx/issues/11162

Many thanks. For now I would probably need to disable my sidebars at all. On ReadTheDocs (which uses Sphinx 1.8.6), my project sidebar looks much nicer (https://lena.readthedocs.io/en/latest/flow.html).

electric-coder commented 11 months ago

@ynikitenko The issue is that RTD theme can dynamically adjust toctree depth by reading individual .. toctree:: directive declarations. That's a feature most Sphinx themes just don't have because it requires programing the theme so that templating and JavaScript work together to generate the toctree depths correctly in the sidebar.

Why couldn't it be added to the nature theme as well? (...) Why don't add other options to the "nature" theme? Maybe also to other themes, but I'm using that one.

That's a feature request specific to the Sphinx Nature Theme. However, most themes don't support dynamic toctree depth like the RTD theme, or PyData theme do. That feature is supported by just a few of the more recent Sphinx themes, and none of them are maintained by the Sphinx core team. The general solution the community is going for is migrating to modern 3rd party themes that are actively maintained or just structure your documentation's .rst depth to adjust to a single setting when using the older themes.

Since there are well supported alternatives I take it the community doesn't consider this a priority and I can only imagine it would take lots of work to implement.