Skip to content

Commit 761685f

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 761685f

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

.github/workflows/docs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
west build -t rustdoc -b qemu_cortex_m3 docgen
4848
mkdir rustdocs
4949
mv build/rust/target/thumbv7m-none-eabi/doc rustdocs/nostd
50-
cp docs/top-index.html rustdocs/index.html
5150
5251
- name: Build build documentation
5352
working-directory: zephyr-lang-rust
@@ -56,6 +55,12 @@ jobs:
5655
cargo doc
5756
mv target/doc ../rustdocs/std
5857
58+
- name: Inect commit details into top-level commit.
59+
working-directory: zephyr-lang-rust
60+
run: python3 etc/add-hash.py
61+
env:
62+
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
63+
5964
- name: Upload docs artifact
6065
uses: actions/upload-artifact@v4
6166
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", "HEAD"], 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)