Skip to content

Commit

Permalink
doc: boards: extensions: add link to board source to sidebar
Browse files Browse the repository at this point in the history
Similar to how we have a button in code samples' READMEs,
this helps direcly taking the reader to the board's sources
on GitHub

Signed-off-by: Benjamin Cabé <[email protected]>
  • Loading branch information
kartben committed Jan 31, 2025
1 parent b9fa7b9 commit 4853a08
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
15 changes: 15 additions & 0 deletions doc/_extensions/zephyr/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,21 @@ def convert_node(self, node):
field += field_body
field_list += field

gh_link = gh_link_get_url(self.app, self.env.docname)
gh_link_button = nodes.raw(
"",
f"""
<div id="board-github-link">
<a href="{gh_link}/../.." class="btn btn-info fa fa-github"
target="_blank">
Browse board sources
</a>
</div>
""",
format="html",
)
sidebar += gh_link_button

# Move the sibling nodes under the new section
new_section.extend(siblings_to_move)

Expand Down
22 changes: 18 additions & 4 deletions doc/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,10 @@ li>a.code-sample-link.reference.internal.current {
}
}

.sidebar.board-overview {
color: var(--admonition-note-color);
}

.sidebar.board-overview .sidebar-title {
font-family: var(--header-font-family);
background: var(--admonition-note-title-background-color);
Expand All @@ -1137,10 +1141,6 @@ li>a.code-sample-link.reference.internal.current {
text-align: center;
}

.sidebar.board-overview * {
color: var(--admonition-note-color);
}

.sidebar.board-overview figure {
padding: 1rem;
margin-bottom: -1rem;
Expand Down Expand Up @@ -1175,3 +1175,17 @@ li>a.code-sample-link.reference.internal.current {
.sidebar.board-overview dl.field-list>dd code {
font-size: 0.9em;
}

.sidebar.board-overview #board-github-link {
text-align: center;
margin-bottom: 1em;
font-size: 0.9em;
}

.sidebar.board-overview #board-github-link a {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width:80%;
}

0 comments on commit 4853a08

Please sign in to comment.