mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-03-12 11:03:34 -05:00
71 lines
2.0 KiB
Bash
Executable File
71 lines
2.0 KiB
Bash
Executable File
#!/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 ""
|