#!/bin/bash # TinyTorch Website Build Script # Jupyter Book 1.x (Sphinx) Build System # Quick and easy: ./docs/build.sh (from root) or ./build.sh (from docs/) set -e # Exit on error echo "๐Ÿ—๏ธ Building TinyTorch documentation website (Jupyter Book 1.x)..." echo "" # Detect where we're running from and navigate to docs directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DOCS_DIR="" PROJECT_ROOT="" if [ -f "_config.yml" ]; then # Already in docs directory DOCS_DIR="$(pwd)" PROJECT_ROOT="$(dirname "$DOCS_DIR")" elif [ -f "docs/_config.yml" ]; then # In root directory PROJECT_ROOT="$(pwd)" DOCS_DIR="$(pwd)/docs" cd "$DOCS_DIR" echo "๐Ÿ“‚ Changed to docs directory: $DOCS_DIR" else echo "โŒ Error: Cannot find docs directory with _config.yml" echo " Run from project root or docs/ directory" exit 1 fi # Activate virtual environment if it exists and we're not already in it if [ -z "$VIRTUAL_ENV" ] && [ -f "$PROJECT_ROOT/.venv/bin/activate" ]; then echo "๐Ÿ”ง Activating virtual environment..." source "$PROJECT_ROOT/.venv/bin/activate" elif [ -z "$VIRTUAL_ENV" ]; then echo "โš ๏ธ Warning: No virtual environment detected" echo " Recommend running: source scripts/activate-tinytorch" fi # Verify jupyter-book is available if ! command -v jupyter-book &> /dev/null; then echo "โŒ Error: jupyter-book not found" echo " Install with: pip install jupyter-book" exit 1 fi echo "๐Ÿ“ฆ Using: $(which jupyter-book)" echo " Version: $(jupyter-book --version | head -1)" echo "" # Clean previous build if [ -d "_build" ]; then echo "๐Ÿงน Cleaning previous build..." jupyter-book clean . echo "" fi # Build the site echo "๐Ÿš€ Building Jupyter Book site..." echo "" jupyter-book build . --all echo "" echo "โœ… Build complete!" echo "" echo "๐Ÿ“– To view the site locally:" echo " python -m http.server 8000 --directory _build/html" echo " Then open: http://localhost:8000" echo ""