Skip to content

Commit

Permalink
doc: Make code-samples admonition collapsible
Browse files Browse the repository at this point in the history
Use sphinx-toggle to make "Related code samples" collapsible.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
  • Loading branch information
kartben authored and carlescufi committed Sep 6, 2023
1 parent 5832f6e commit b2977b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/_extensions/zephyr/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def run(self, **kwargs: Any) -> None:
if len(code_samples) > 0:
admonition = nodes.admonition()
admonition += nodes.title(text="Related code samples")
admonition["collapsible"] = "" # used by sphinx-immaterial theme
admonition["classes"].append("related-code-samples")
admonition["classes"].append("dropdown") # used by sphinx-togglebutton extension
sample_ul = nodes.bullet_list()
for code_sample in sorted(code_samples, key=lambda x: x["name"]):
sample_para = nodes.paragraph()
Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"zephyr.vcs_link",
"notfound.extension",
"sphinx_copybutton",
"sphinx_togglebutton",
"zephyr.external_content",
"zephyr.domain",
]
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sphinxcontrib-svg2pdfconverter
pygments>=2.9
sphinx-notfound-page
sphinx-copybutton
sphinx-togglebutton

# YAML validation. Used by zephyr_module.
PyYAML>=5.1
Expand Down

0 comments on commit b2977b7

Please sign in to comment.