collapse
¶
Adds a collapsible section to an HTML page using a details element.
New in version 2.5.0.
Enable sphinx_toolbox.collapse
by adding the following
to the extensions
variable in your conf.py
:
extensions = [
...
'sphinx_toolbox.collapse',
]
For more information see https://www.sphinx-doc.org/en/master/usage/extensions#third-party-extensions .
Usage¶
-
.. collapse::
[label]¶ Adds a collapsible section to an HTML page using a details element.
With non-HTML builders, the content will be added as-is.
.. collapse:: Details Something small enough to escape casual notice. .. collapse:: A Different Label :class: custom-summary :name: summary0 Something else that might escape notice. .. collapse:: A long code block .. code-block:: python print("Not really")
Details
Something small enough to escape casual notice.
A Different Label
Something else that might escape notice.
A long code block
print("Not really")
-
:open:
(flag)¶ The
:open:
option can be used to have the section open by default.New in version 3.0.0.
.. collapse:: Open :open: This section is open by default.
Open
This section is open by default.
-
API Reference¶
Classes:
|
A Sphinx directive to add a collapsible section to an HTML page using a details element. |
|
Node that represents a collapsible section. |
Functions:
|
Visit a |
|
Depart a |
|
Setup |
-
class
CollapseDirective
(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]¶ Bases:
SphinxDirective
A Sphinx directive to add a collapsible section to an HTML page using a details element.
Methods:
run
()Process the content of the directive.
-
class
CollapseNode
(rawsource='', label=None, *children, **attributes)[source]¶ Bases:
Body
,Element
Node that represents a collapsible section.
-
visit_collapse_node
(translator, node)[source]¶ Visit a
CollapseNode
.- Parameters:
translator (
HTML5Translator
)node (
CollapseNode
) – The node being visited.
-
depart_collapse_node
(translator, node)[source]¶ Depart a
CollapseNode
.- Parameters:
translator (
HTML5Translator
)node (
CollapseNode
) – The node being visited.
-
setup
(app)[source]¶ Setup
sphinx_toolbox.collapse
.- Parameters:
app (
Sphinx
) – The Sphinx application.- Return type: