Skip to content

Commit e842336

Browse files
committed
docs: Add latest commit to top of index
Insert `git show --stat HEAD` into the template for the top-level docs, to make it easy to see what a build was generated for. Signed-off-by: David Brown <[email protected]>
1 parent 4c8f3e1 commit e842336

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.github/workflows/docs.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222
with:
2323
path: zephyr-lang-rust
24+
fetch-depth: 0 # Ensure full history is available
2425

2526
- name: Set up Python
2627
uses: actions/setup-python@v5
@@ -47,7 +48,6 @@ jobs:
4748
west build -t rustdoc -b qemu_cortex_m3 docgen
4849
mkdir rustdocs
4950
mv build/rust/target/thumbv7m-none-eabi/doc rustdocs/nostd
50-
cp docs/top-index.html rustdocs/index.html
5151
5252
- name: Build build documentation
5353
working-directory: zephyr-lang-rust
@@ -56,6 +56,12 @@ jobs:
5656
cargo doc
5757
mv target/doc ../rustdocs/std
5858
59+
- name: Inject commit details into top-level commit.
60+
working-directory: zephyr-lang-rust
61+
env:
62+
COMMIT_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
63+
run: python3 etc/add-hash.py
64+
5965
- name: Upload docs artifact
6066
uses: actions/upload-artifact@v4
6167
with:

docs/top-index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ <h1>Documentation Index</h1>
1010
<li><a href="nostd/zephyr/index.html">zephyr crate Documentation</a></li>
1111
<li><a href="std/zephyr_build/index.html">zephyr_build support Documentation</a></li>
1212
</ul>
13+
<pre>
14+
{{COMMIT}}
15+
</pre>
1316
</body>
1417
</html>

etc/add-hash.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /usr/bin/env python
2+
3+
import os
4+
import subprocess
5+
6+
input = "./docs/top-index.html"
7+
output = "rustdocs/index.html"
8+
9+
# Get the commit from github (otherwise, we are likely to just see a merge commit. Default to HEAD
10+
# if not provided.)
11+
commit_sha = os.getenv("COMMIT_SHA", "HEAD")
12+
13+
try:
14+
commit_info = subprocess.check_output(["git", "show", "--stat", commit_sha], text=True)
15+
except subprocess.CalledProcessError as e:
16+
print(f"Error getting commit info: {e}")
17+
commit_info = "Error retrieving commit details.\n"
18+
19+
with open(output, "w") as outfile:
20+
with open(input, "r") as file:
21+
for line in file:
22+
if "{{COMMIT}}" in line:
23+
outfile.write(commit_info)
24+
else:
25+
outfile.write(line)

0 commit comments

Comments
 (0)