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 committed Aug 30, 2023
1 parent 8630db5 commit 76177ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/_extensions/zephyr/code-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def process_related_code_sample_nodes(app, doctree, fromdocname):
if len(code_samples) > 0:
admonition = nodes.admonition()
admonition += nodes.title(text="Related code samples")
admonition["collapsible"] = ""
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 code_samples:
# Create a list item such as:
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.code-sample",
]
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 76177ff

Please sign in to comment.