JuliaDocs / Documenter.jl

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

Collapsed example blocks #2238

Open ArnoStrouwen opened 1 year ago

ArnoStrouwen commented 1 year ago

In the SciML documentation, there are a lot of tutorial pages where the full tutorial is posted at the top. This is done so that users can copy the full example with one click.

After that, the same example is repeated, but with text in between the code. If you are just interested in the explanation, you have to scroll past a large block of code. e.g.: https://docs.sciml.ai/ModelingToolkit/stable/tutorials/acausal_components/#Copy-Paste-Example

It would be nice if we could collapse the full code and only expand it if the user clicks on it, but still have the copy button available without expanding it.

mortenpi commented 1 year ago

Do you want this to be something that the docs author explicitly declares that "this example block is collapsed by default" or that we just automatically collapse large code blocks?

One possible automatic UI here that we could try is that if it's more than N lines, then we kinda semi-collapse, showing the top part, and have a fade on the bottom with "click here to see the full example".

ArnoStrouwen commented 1 year ago

I think declaring it explicitly would be best, with the default argument non-collapsed.