Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Build outside the checkout
# The doc scripts are to find what cargo built where cargo put it,
# which CARGO_TARGET_DIR or a configured target-dir moves out of target/.
run: echo "CARGO_TARGET_DIR=$RUNNER_TEMP/target" >> "$GITHUB_ENV"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.97.1
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/+docs-target-dir.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`scripts/build-docs.sh` and `docs/examples/sidecar-demo.sh` ask `cargo metadata` for the target directory, so the book's transcripts and API docs come from the builds cargo just made when `CARGO_TARGET_DIR` or a configured target-dir moves them out of `target/`.
They read `target/` under the checkout, and ran stale binaries or none; the docs workflow now builds outside the checkout.
10 changes: 7 additions & 3 deletions docs/examples/sidecar-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
set -euo pipefail

root=$(cd "$(dirname "$0")/../.." && pwd)
sidecar="$root/target/debug/rfc9162-sidecar"
demo_key="$root/target/debug/demo_key"
show="$root/target/debug/show_checkpoint"
# Wherever cargo puts its builds: CARGO_TARGET_DIR or a configured
# target-dir moves them out of target/.
target=$(cd "$root" && cargo metadata --locked --format-version 1 --no-deps |
python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')
sidecar="$target/debug/rfc9162-sidecar"
demo_key="$target/debug/demo_key"
show="$target/debug/show_checkpoint"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
cd "$work"
Expand Down
9 changes: 7 additions & 2 deletions scripts/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ if ! command -v mdbook >/dev/null 2>&1; then
exit 1
fi

# Wherever cargo puts its builds: CARGO_TARGET_DIR or a configured
# target-dir moves them out of target/.
target=$(cargo metadata --locked --format-version 1 --no-deps |
python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')

export RUSTDOCFLAGS="-D warnings"
rm -rf "$root/target/doc"
rm -rf "$target/doc"
cargo doc --locked --no-deps -p rfc9162 -p rfc9162-tiles -p rfc9162-log
bash "$root/scripts/regen-doc-output.sh"

Expand All @@ -28,4 +33,4 @@ rm -f "$err"

rm -rf "$root/docs/book/api"
mkdir -p "$root/docs/book/api"
cp -a "$root/target/doc/." "$root/docs/book/api/"
cp -a "$target/doc/." "$root/docs/book/api/"
Loading