pradyunsg / furo

A clean customizable documentation theme for Sphinx
https://pradyunsg.me/furo/quickstart
MIT License
2.59k stars 301 forks source link

Add option to collapse navbar #748

Open cmaureir opened 6 months ago

cmaureir commented 6 months ago

For large projects, the generation of non-collapsed navbar is frequently a reason for long build periods.

Motivated by the current option available in other themes, like sphinx-book-theme, this patch includes the 'collapse_navbar' option to the theme configuration.

cmaureir commented 6 months ago

Hey @pradyunsg :wave:

I was trying to implement this with a simple approach, but because the context defined in __init__.py cannot be acceded from the html templates, I was unable to call the furo_navigation_tree with the collapse option.

Naively, I tried to have both function as well defined in the context:

context["furo_navigation_tree"] = _compute_navigation_tree(context)
context["furo_navigation_tree_collapsed"] = _compute_navigation_tree(context, collapse=True)

but of course, that was generating both trees rather than the option selected, so there was no improvement.

The motivation comes from the Qt for Python project, which you might remember uses furo, where we have around 2500 rst files, so with this the sphinx-build process was reduced from 20 minutes, so 2 minutes.

If you believe there is a simpler way to achieve this, I can happily modify the PR :)

Thanks for your time.

Eric-Arellano commented 6 months ago

See https://github.com/pradyunsg/furo/pull/674 for a similar PR and discussion about this topic, including how the Pydata theme recently sped things up in https://github.com/pydata/pydata-sphinx-theme/pull/1609.

cmaureir commented 5 months ago

Thanks for the insights @Eric-Arellano :tada: I was following a similar topic from sphinx-book-theme https://github.com/executablebooks/sphinx-book-theme/issues/561 to get the idea for this flag.

At least at the moment we are using this variation and it works well with our documentation process, the speed up is considerable.