autofunction Collapse Sections

360 views
Skip to first unread message

Stephen O'Neill

unread,
Sep 10, 2019, 1:26:24 AM9/10/19
to sphinx-users
Hey Gang,

I'm having a bit of trouble figuring out how to set up some clickable/collapsible definitions.  I found some great information here: https://stackoverflow.com/questions/2454577/sphinx-restructuredtext-show-hide-code-snippets on how to add collapsible sections in the html output by sphinx, but I can't quite get things how I'd like them.  I'm using the combo of _templates/page.html and _static/custom.css to build on the container directive as shown in the answer by pbauer in the stack overflow link.  The problem, is that I'd like part of the autofunction:: output to appear in the collapsible header, and the actual docstring to appear as the collapsible section content.  Does anyone know of an extension which will do something like this?

Example - currently I have .rst files with a section like this:

.. container:: toggle

    .. container:: heading

        ManualHeaderText

    .. autofunction:: my.module.function

What I would like is something like this:

.. container:: toggle

    .. container:: heading

        ..auto_function_signature_only:: my.module.function

    .. auto_function_docstring_content:: my.module.function

Does anyone know how to make this happen?  I think my docs would be a heck of a lot more usable if I could set it up so that only the function signatures were visible by default, and clicking on them yielded the additional content.

A pre-emptive thank you for any help or advice!

Best,
Steve O'Neill

Reply all
Reply to author
Forward
0 new messages