Skip to content

Commit 52afb90

Browse files
committed
Get rustdoc flags from Cargo.toml.
1 parent 21dc2dd commit 52afb90

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
CARGO_TERM_COLOR: always
12-
RUSTFLAGS: '-D warnings'
12+
RUSTFLAGS: "-D warnings"
1313

1414
jobs:
1515
# Run MIRI tests on nightly
@@ -182,11 +182,6 @@ jobs:
182182
doc:
183183
name: doc
184184
runs-on: ubuntu-latest
185-
strategy:
186-
matrix:
187-
target:
188-
- x86_64-unknown-linux-gnu
189-
- thumbv7m-none-eabi
190185
steps:
191186
- name: Checkout
192187
uses: actions/checkout@v4
@@ -213,14 +208,40 @@ jobs:
213208
${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
214209
${{ runner.OS }}-build-
215210
216-
- name: Install nightly Rust with target (${{ matrix.target }})
211+
- name: Get metadata
212+
id: metadata
213+
run: |
214+
set -euo pipefail
215+
216+
docsrs_metadata="$(cargo metadata --format-version 1 | jq '.packages[] | select(.name == "heapless") | .metadata.docs.rs')"
217+
features=($(jq --raw-output '.features[]' <<< "${docsrs_metadata}"))
218+
rustdocflags=(-D warnings --cfg docsrs $(jq --raw-output '.["rustdoc-args"][]' <<< "${docsrs_metadata}"))
219+
targets=($(jq --raw-output '.targets[]' <<< "${docsrs_metadata}"))
220+
221+
echo "features=${features[*]}" >> "${GITHUB_OUTPUT}"
222+
echo "rustdocflags=${rustdocflags[*]}" >> "${GITHUB_OUTPUT}"
223+
echo "targets=${targets[*]}" >> "${GITHUB_OUTPUT}"
224+
225+
- name: Install nightly Rust with targets (${{ steps.metadata.outputs.targets }})
217226
uses: dtolnay/rust-toolchain@nightly
218227
with:
219-
targets: ${{ matrix.target }}
228+
targets: ${{ steps.metadata.outputs.targets }}
220229

221230
- name: cargo rustdoc
222-
env: {"RUSTDOCFLAGS": "-D warnings --cfg docsrs"}
223-
run: cargo rustdoc --target=${{ matrix.target }} --features="alloc bytes defmt mpmc_large portable-atomic-critical-section serde ufmt"
231+
run: |
232+
set -euo pipefail
233+
234+
targets=(${targets})
235+
236+
for target in "${targets[@]}"; do
237+
set -x
238+
cargo rustdoc --target "${target}" --features "${features}"
239+
set +x
240+
done
241+
env:
242+
features: ${{ steps.metadata.outputs.features }}
243+
RUSTDOCFLAGS: ${{ steps.metadata.outputs.rustdocflags }}
244+
targets: ${{ steps.metadata.outputs.targets }}
224245

225246
# Run cpass tests
226247
testcpass:

0 commit comments

Comments
 (0)