#!/bin/bash # Checks a book of the guides against the current PageTop code: its links, and that every Rust # example compiles (and runs, if it is not marked `no_run`). See "Checking the guides" in README.md. # # Usage: tools/doccheck.sh [book dir] (default: the latest Spanish guide) set -u ROOT="$(cd "$(dirname "$0")/.." && pwd)" BOOK="$(cd "${1:-$ROOT/doc/v0.6/es}" && pwd)" CRATE="$ROOT/tools/doccheck" OUT="$CRATE/target/book" FAILED=0 echo "== Links" rm -rf "$OUT" if mdbook build "$BOOK" -d "$OUT" >/dev/null 2>&1; then python3 "$CRATE/check_links.py" "$OUT" || FAILED=1 else echo "mdbook build failed"; FAILED=1 fi echo "== Examples" python3 "$CRATE/extract.py" "$BOOK/src" "$CRATE" cd "$CRATE" || exit 1 if ! cargo build -j 2 --examples; then FAILED=1 else for example in examples/*_run.rs; do [ -e "$example" ] || continue name="$(basename "$example" .rs)" if ! "./target/debug/examples/$name" >/dev/null; then echo "run failed: $name"; FAILED=1 fi done fi echo "== Tests" cargo test -j 2 --tests || FAILED=1 if [ "$FAILED" -eq 0 ]; then echo "OK: the guide matches the current PageTop code"; fi exit "$FAILED"