#!/usr/bin/env bash
# Generate auto-generated documentation pages for mdBook.
# Run this before `mdbook build`.
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DOCS_DIR="$REPO_ROOT/docs"

# --- Generate docs/README.md from root README.md ---
{
    echo "<!-- This file is auto-generated by scripts/generate-examples-docs.sh -->"
    echo "<!-- Do not edit manually — edit the root README.md instead. -->"
    echo ""
    # Convert ## headers to **bold** for mdBook sidebar cleanliness
    sed -E 's/^## (.*)/\*\*\1\*\*/' "$REPO_ROOT/README.md"
} > "$DOCS_DIR/README.md"

echo "Generated docs/README.md"
