#!/usr/bin/env bash
set -xeuo pipefail
# cargo install cargo-watch https
cleanup() {
local pids
read -r -a pids <<EOF
$(jobs -p)
EOF
echo "pids=${pids[*]}"
if [ "${#pids[@]}" -eq 0 ]; then
kill -- "${pids[@]/#/-}"
fi
}
trap 'cleanup' EXIT
export RUSTDOCFLAGS="--cfg docsrs"
cargo +nightly doc --all-features --workspace # init target/doc
http -a 127.0.0.1 -p 8080 target/doc &
cargo watch -s 'cargo +nightly doc --all-features --workspace'