#!/bin/bash set -euo pipefail # Build the Sphinx HTML documentation. # # Usage: make_doc.sh [output_dir] # output_dir where the rendered HTML is written (default: ./public). # Relative paths are resolved against the caller's working # directory, so the frontend build can point this at frontend/dist/docs. # # The Python interpreter can be overridden with $PYTHON. Otherwise the newest # available python3.x is used (the bare "python3" is often too old). OUT="${1:-public}" if [ -z "${PYTHON:-}" ]; then for candidate in python3.13 python3.12 python3.11 python3; do if command -v "$candidate" >/dev/null 2>&1; then PYTHON="$candidate" break fi done fi if [ -z "${PYTHON:-}" ]; then echo "No python3 interpreter found" >&2 exit 1 fi echo "Using $PYTHON ($("$PYTHON" --version 2>&1))" # Resolve the output directory to an absolute path before we change directories. mkdir -p "$OUT" OUT="$(cd "$OUT" && pwd)" # Run from the repository root regardless of where the script was invoked from. cd "$(dirname "$0")" "$PYTHON" -m venv tmp_venv/ source tmp_venv/bin/activate pip install -r docs/requirements.txt sphinx-build -b html docs "$OUT" rm -rf tmp_venv/