readthedocs / sphinx_rtd_theme

Sphinx theme from Read the Docs
https://sphinx-rtd-theme.readthedocs.io/
MIT License
4.77k stars 1.73k forks source link

Collapsable Code Blocks #402

Closed nelson-liu closed 3 years ago

nelson-liu commented 7 years ago

Hi, I was wondering whether it would be possible to use collapsable code blocks with this theme (i.e. as done here: http://stackoverflow.com/questions/2454577/sphinx-restructuredtext-show-hide-code-snippets/25543713#25543713). I couldn't find anything in the code that would let me do this; consider this a feature request?

Thanks!

Blendify commented 7 years ago

This is not possible currently and I think it would be better if you override the theme yourself. @agjohnson Do we share the same opinion here?

Also: http://guido.vonrudorff.de/sphinx-documentation-collapse-content/

nelson-liu commented 7 years ago

Thanks for the quick response @Blendify , by override do you mean fork and modify the layouts.html / static_ folder ourselves? (and then use it by adding it to the doc/ folder or wherever sphinx looks for themes)

Blendify commented 7 years ago

No you can create your own template overrides with sphinx. See http://www.sphinx-doc.org/en/stable/templating.html

nelson-liu commented 7 years ago

Got it, thanks for the info! Feel free to close whenever; not sure if this is something you guys want to consider for the template.

Thanks for all your work on RTD, it really makes writing and hosting docs so much easier!

yangxi510207 commented 7 years ago

402

On 03/24/2017 07:22, Nelson Liu wrote:

Got it, thanks for the info! Feel free to close whenever; not sure if this is something you guys want to consider for the template.

Thanks for all your work on RTD, it really makes writing and hosting docs so much easier!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Un1Gfn commented 3 years ago

simple raw HTML <details> hack w/ zero JS

agjohnson commented 3 years ago

Agreed, an extension would probably be better here.

simple raw HTML

hack w/ zero JS

Just noting from this SO link that a user linked to a sphinx extension that accomplishes code blocks that can be hidden, though I have not tested the extension at all:

https://github.com/scopatz/hiddencode