-
Notifications
You must be signed in to change notification settings - Fork 224
96 lines (82 loc) · 4.33 KB
/
Copy pathgenerate-docs.yml
File metadata and controls
96 lines (82 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Generate & push docs
on:
workflow_dispatch:
inputs:
gen_hal_docs:
description: 'Generate hal docs (yes/no)'
required: true
default: 'yes'
jobs:
gen-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v7
- name: Install Rust
run: |
rustup set profile minimal
rustup target add thumbv6m-none-eabi
rustup target add thumbv7em-none-eabihf
- name: Generate HAL docs
if: github.event.inputs.gen_hal_docs == 'yes'
shell: bash
run: |
set -ex
docs_path="$(pwd)/docs"
mkdir -pv "${docs_path}"
(cd "$docs_path" && git init && git checkout -b main)
for variant in $(cat crates.json | jq -Mr -c '.hal_doc_variants | keys[]');
do
(
feature_str=$(cat crates.json | jq -Mr --arg variant "${variant}" -c '.hal_doc_variants[$variant].features | join(",")')
target=$(cat crates.json | jq -Mr --arg variant "${variant}" -c '.hal_doc_variants[$variant].target')
mkdir -pv "${docs_path}/${variant}"
cd hal
cargo doc --features "${feature_str}" --target "${target}" --release --target-dir "${docs_path}/${variant}"
rm -rf "${docs_path}/${variant}/${target}/release/deps"
rm -rf "${docs_path}/${variant}/release"
)
done
echo '<!DOCTYPE html>' > "${docs_path}/index.html"
echo '<html lang="en">' >> "${docs_path}/index.html"
echo ' <head>' >> "${docs_path}/index.html"
echo ' <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">' >> "${docs_path}/index.html"
echo ' <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">' >> "${docs_path}/index.html"
echo ' <style>.label { margin-right: 0.2em; } </style>' >> "${docs_path}/index.html"
echo ' </head>' >> "${docs_path}/index.html"
echo ' <body class="container">' >> "${docs_path}/index.html"
echo ' <h1>per-chip atsamd-HAL docs</h1>' >> "${docs_path}/index.html"
echo ' ' >> "${docs_path}/index.html"
echo ' <table class="table table-bordered">' >> "${docs_path}/index.html"
echo ' <thead>' >> "${docs_path}/index.html"
echo ' <tr><th>Chip</th><th>Features</th></tr>' >> "${docs_path}/index.html"
echo ' </thead>' >> "${docs_path}/index.html"
echo ' <tbody>' >> "${docs_path}/index.html"
for variant in $(cat crates.json | jq -Mr -c '.hal_doc_variants | keys[]');
do
target=$(cat crates.json | jq -Mr --arg variant "${variant}" -c '.hal_doc_variants[$variant].target')
features_html=$(cat crates.json | jq -Mr --arg variant "${variant}" -c '.hal_doc_variants[$variant].features | map("<span class=\"label label-default\">", . , "</span>") | join(" ")')
echo ' <tr>' >> "${docs_path}/index.html"
echo " <td><a href='${variant}/${target}/doc/atsamd_hal/index.html'>${variant}</a></td>" >> "${docs_path}/index.html"
echo " <td>${features_html}</td>" >> "${docs_path}/index.html"
echo ' </tr>' >> "${docs_path}/index.html"
done
echo ' </tbody>' >> "${docs_path}/index.html"
echo ' </table>' >> "${docs_path}/index.html"
echo ' </body>' >> "${docs_path}/index.html"
echo '</html>' >> "${docs_path}/index.html"
- name: Checkout pages branch
uses: actions/checkout@v7
with:
ref: gh-pages
path: gh-pages
- name: Commit documentation changes
run: |
rsync --archive --delete --exclude .git docs/ gh-pages/
cd gh-pages
touch .nojekyll
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
git push