Skip to content

Commit 4b0eb0b

Browse files
committed
fix(justfile): Prevent overwriting of nethsm docs in docs recipe
Due to a bug in cargo the docs of nethsm-cli would overwrite those of nethsm. Prevent this by selectively generating docs and moving relevant dirs around. Related-to: rust-lang/cargo#6313 Signed-off-by: David Runge <[email protected]>
1 parent ce9b186 commit 4b0eb0b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

justfile

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ lint:
188188
just lint-recipe 'generate shell_completions nethsm-cli'
189189
just lint-recipe 'is-workspace-member nethsm'
190190
just lint-recipe 'release nethsm'
191+
just lint-recipe docs
191192
just lint-recipe flaky
192193
just lint-recipe test
193194
just lint-recipe 'ensure-command test'
@@ -216,8 +217,29 @@ build project *cargo_build_options:
216217

217218
# Build local documentation
218219
docs:
220+
#!/usr/bin/env bash
221+
set -euo pipefail
222+
219223
just ensure-command cargo mold
220-
RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --no-deps
224+
225+
readonly target_dir="${CARGO_TARGET_DIR:-$PWD/target}"
226+
mapfile -t workspace_members < <(just get-workspace-members 2>/dev/null)
227+
228+
# NOTE: nethsm-cli's executable documentation shadows the nethsm documentation (because of cargo bug: https://github.com/rust-lang/cargo/issues/6313)
229+
for name in "${workspace_members[@]}"; do
230+
RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --no-deps --package "$name"
231+
case "$name" in
232+
nethsm)
233+
mv "$target_dir/doc/nethsm" "$target_dir/doc/nethsm.tmp"
234+
;;
235+
nethsm-cli)
236+
rm -rf "$target_dir/doc/nethsm"
237+
;;
238+
*)
239+
;;
240+
esac
241+
done
242+
mv "$target_dir/doc/nethsm.tmp" "$target_dir/doc/nethsm"
221243

222244
# Runs all unit tests. By default ignored tests are not run. Run with `ignored=true` to run only ignored tests
223245
test:

0 commit comments

Comments
 (0)