Skip to content

Commit

Permalink
fix(justfile): Prevent overwriting of nethsm docs in docs recipe
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dvzrv committed Dec 3, 2024
1 parent ce9b186 commit 4b0eb0b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ lint:
just lint-recipe 'generate shell_completions nethsm-cli'
just lint-recipe 'is-workspace-member nethsm'
just lint-recipe 'release nethsm'
just lint-recipe docs
just lint-recipe flaky
just lint-recipe test
just lint-recipe 'ensure-command test'
Expand Down Expand Up @@ -216,8 +217,29 @@ build project *cargo_build_options:

# Build local documentation
docs:
#!/usr/bin/env bash
set -euo pipefail
just ensure-command cargo mold
RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --no-deps

readonly target_dir="${CARGO_TARGET_DIR:-$PWD/target}"
mapfile -t workspace_members < <(just get-workspace-members 2>/dev/null)

# NOTE: nethsm-cli's executable documentation shadows the nethsm documentation (because of cargo bug: https://github.com/rust-lang/cargo/issues/6313)
for name in "${workspace_members[@]}"; do
RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --no-deps --package "$name"
case "$name" in
nethsm)
mv "$target_dir/doc/nethsm" "$target_dir/doc/nethsm.tmp"
;;
nethsm-cli)
rm -rf "$target_dir/doc/nethsm"
;;
*)
;;
esac
done
mv "$target_dir/doc/nethsm.tmp" "$target_dir/doc/nethsm"

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

0 comments on commit 4b0eb0b

Please sign in to comment.