Skip to content

Commit c487259

Browse files
kartbennashif
authored andcommitted
doc: extensions: samples: Add "browse source code" button
One of the first thing one wants to do when reading about a code sample is checking the code itself. This commit adds a button to directly take the user to the code sample' source code on GitHub. Signed-off-by: Benjamin Cabé <[email protected]>
1 parent 06a89bc commit c487259

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/_extensions/zephyr/domain/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ def convert_node(self, node):
102102
new_section = nodes.section(ids=[node["id"]])
103103
new_section += nodes.title(text=node["name"])
104104

105+
gh_link = gh_link_get_url(self.app, self.env.docname)
106+
gh_link_button = nodes.raw(
107+
"",
108+
f"""
109+
<a href="{gh_link}/.." class="btn btn-info fa fa-github"
110+
target="_blank" style="text-align: center;">
111+
Browse source code on GitHub
112+
</a>
113+
""",
114+
format="html",
115+
)
116+
new_section += nodes.paragraph("", "", gh_link_button)
117+
105118
# Move the sibling nodes under the new section
106119
new_section.extend(siblings_to_move)
107120

0 commit comments

Comments
 (0)