#!/bin/sh
# Reproducible local docs build and checked-in export drift gate.
set -u
ROOT=$(CDPATH= cd "$(dirname "$0")/../.." && pwd)
PY=""
for candidate in python3 python py; do
  command -v "$candidate" >/dev/null 2>&1 || continue
  if "$candidate" -c 'import pathlib' >/dev/null 2>&1; then
    PY=$candidate
    break
  fi
done
[ -n "$PY" ] || { echo "FAIL: Python is required for the docs gate" >&2; exit 2; }
exec "$PY" "$ROOT/ci/docs/build-docs.py" --root "$ROOT" --check
