JuliaDocs / Documenter.jl

A documentation generator for Julia.
https://documenter.juliadocs.org
MIT License
811 stars 479 forks source link

Add "collapse/expand all" functionality #1393

Closed cloudgiant closed 1 year ago

cloudgiant commented 4 years ago

For people that already know other programming languages, it would help a lot to get an overview of what's available in a package/module by looking at the list of available functions/types (without all the detailed explanations). However, in the current implementation of documenter template where each article is implemented like a card (with header + section) and a margin between each of them, it is (at least for me) not possible to do that easily. I have already seen that there is the index functionality but it doesn't seem to be in use that much and it adds a bit of clutter that can be avoided by collapsing the sections of each article. This would allow a somewhat implicit implementation of the index with additional information for different function groups with markdown in-between. I have created a Tampermonkey userscript to evaluate this idea as a proof-of-concept:

collapse_expand

(Tampermonkey userscript gist: https://gist.github.com/cloudgiant/d02dca129d79558cab1a8cbbd820f0a7 . You can try it out on official julia docs after installing: https://docs.julialang.org/en/v1/base/collections/)

This script just adds an expand/collapse articles button on top right (It will of course need some css love for the proper implementation) and adds an onclick listener for the headers to expand/collapse single articles (Single article expand/collapse functionality can also be triggered by a button if an onclick listener for the header is a bit too much).

In this crude implementation, the methods are shown duplicated. This problem can be solved by either showing signatures or grouping the methods together for the function name (with number of methods maybe?). Ideally the header would also show a single sentence summary in the collapsed state.

I think a variation of this functionality would be beneficial for reference part of every package documentation, especially for newcomer julia developers.

mortenpi commented 4 years ago

I think would be a great thing to have, if you'd be willing to take a stab at implementing this. Generally, Documenter-based docs (including the Julia manual) tend to have these hugely long API reference pages, and I think this would really help navigating those long lists.

Hetarth02 commented 1 year ago

@mortenpi This can be achieved using slideToggle() function of jquery. If it is up for grabs, I am happy to contribute.

mortenpi commented 1 year ago

Pretty sure it's up for grabs.