#!/bin/bash # IGNY8 Documentation Verification Script # Version: 1.8.4 # Purpose: Verify documentation accuracy against codebase set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo "========================================" echo "IGNY8 Documentation Verification" echo "========================================" echo "" ERRORS=0 WARNINGS=0 # Function to increment errors error() { echo -e "${RED}[ERROR]${NC} $1" ((ERRORS++)) } # Function to increment warnings warn() { echo -e "${YELLOW}[WARN]${NC} $1" ((WARNINGS++)) } # Function for success success() { echo -e "${GREEN}[OK]${NC} $1" } # Get script directory SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="$(dirname "$SCRIPT_DIR")" BACKEND_DIR="$ROOT_DIR/backend" FRONTEND_DIR="$ROOT_DIR/frontend" DOCS_DIR="$ROOT_DIR/docs" echo "Root directory: $ROOT_DIR" echo "" # ============================================ # 1. Check root documentation files exist # ============================================ echo "--- Checking Root Documentation Files ---" for file in "INDEX.md" "DESIGN-GUIDE.md" "CHANGELOG.md" "README.md" ".cursorrules"; do if [ -f "$ROOT_DIR/$file" ]; then success "$file exists" else error "$file missing from root" fi done echo "" # ============================================ # 2. Check required docs directories exist # ============================================ echo "--- Checking Documentation Structure ---" for dir in "00-SYSTEM" "10-MODULES" "20-API" "30-FRONTEND" "40-WORKFLOWS" "50-DEPLOYMENT" "60-PLUGINS" "90-REFERENCE"; do if [ -d "$DOCS_DIR/$dir" ]; then success "docs/$dir exists" else warn "docs/$dir missing" fi done echo "" # ============================================ # 3. Count frontend routes vs documented # ============================================ echo "--- Verifying Route Documentation ---" if [ -f "$FRONTEND_DIR/src/App.tsx" ]; then ROUTE_COUNT=$(grep -c "path:" "$FRONTEND_DIR/src/App.tsx" 2>/dev/null || echo "0") ROUTE_COUNT=$(echo "$ROUTE_COUNT" | tr -d '[:space:]') echo "Routes in App.tsx: $ROUTE_COUNT" if [ -f "$DOCS_DIR/30-FRONTEND/PAGES.md" ]; then DOC_ROUTES=$(grep -c "^|.*|.*|" "$DOCS_DIR/30-FRONTEND/PAGES.md" 2>/dev/null || echo "0") DOC_ROUTES=$(echo "$DOC_ROUTES" | tr -d '[:space:]') echo "Routes documented: ~$DOC_ROUTES" if [ "$ROUTE_COUNT" -gt 0 ] 2>/dev/null; then success "Routes appear documented" else success "PAGES.md exists" fi else error "PAGES.md not found" fi else warn "App.tsx not found - skipping route check" fi echo "" # ============================================ # 4. Count models vs documented # ============================================ echo "--- Verifying Model Documentation ---" if [ -d "$BACKEND_DIR" ]; then MODEL_COUNT=$(grep -r "class.*models.Model" "$BACKEND_DIR" --include="*.py" 2>/dev/null | wc -l || echo "0") echo "Models in codebase: $MODEL_COUNT" if [ -f "$DOCS_DIR/90-REFERENCE/MODELS.md" ]; then DOC_MODELS=$(grep -c "^###" "$DOCS_DIR/90-REFERENCE/MODELS.md" 2>/dev/null || echo "0") echo "Models documented: ~$DOC_MODELS" success "Models documentation exists" else error "MODELS.md not found" fi else warn "Backend directory not found" fi echo "" # ============================================ # 5. Count stores vs documented # ============================================ echo "--- Verifying Store Documentation ---" if [ -d "$FRONTEND_DIR/src/store" ]; then STORE_COUNT=$(ls -1 "$FRONTEND_DIR/src/store"/*.ts 2>/dev/null | wc -l || echo "0") STORE_COUNT=$(echo "$STORE_COUNT" | tr -d '[:space:]') echo "Stores in codebase: $STORE_COUNT" if [ -f "$DOCS_DIR/30-FRONTEND/STORES.md" ]; then DOC_STORES=$(grep -c "^###" "$DOCS_DIR/30-FRONTEND/STORES.md" 2>/dev/null || echo "0") echo "Stores documented: ~$DOC_STORES" success "Stores documentation exists" else error "STORES.md not found" fi elif [ -d "$FRONTEND_DIR/src/stores" ]; then STORE_COUNT=$(ls -1 "$FRONTEND_DIR/src/stores"/*.ts 2>/dev/null | wc -l || echo "0") STORE_COUNT=$(echo "$STORE_COUNT" | tr -d '[:space:]') echo "Stores in codebase: $STORE_COUNT" if [ -f "$DOCS_DIR/30-FRONTEND/STORES.md" ]; then DOC_STORES=$(grep -c "^###" "$DOCS_DIR/30-FRONTEND/STORES.md" 2>/dev/null || echo "0") echo "Stores documented: ~$DOC_STORES" success "Stores documentation exists" else error "STORES.md not found" fi else warn "Stores directory not found (checked store/ and stores/)" fi echo "" # ============================================ # 6. Check API docs are accessible # ============================================ echo "--- Verifying API Documentation ---" API_URL="${API_URL:-https://api.igny8.com}" if command -v curl &> /dev/null; then echo "Testing API schema endpoint..." HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/api/schema/" --max-time 10 2>/dev/null || echo "000") if [ "$HTTP_CODE" = "200" ]; then success "API schema endpoint accessible (HTTP $HTTP_CODE)" elif [ "$HTTP_CODE" = "000" ]; then warn "Could not connect to API (timeout or network issue)" else error "API schema endpoint returned HTTP $HTTP_CODE" fi else warn "curl not available - skipping API check" fi echo "" # ============================================ # 7. Check for version consistency # ============================================ echo "--- Checking Version Consistency ---" # Get version from CHANGELOG if [ -f "$ROOT_DIR/CHANGELOG.md" ]; then CHANGELOG_VERSION=$(grep -m1 "Current Version:" "$ROOT_DIR/CHANGELOG.md" | sed 's/.*Version:[* ]*//' | tr -d ' *') echo "CHANGELOG version: $CHANGELOG_VERSION" fi # Get version from package.json if [ -f "$FRONTEND_DIR/package.json" ]; then PACKAGE_VERSION=$(grep -m1 '"version"' "$FRONTEND_DIR/package.json" | sed 's/.*: "\(.*\)".*/\1/') echo "package.json version: $PACKAGE_VERSION" fi if [ -n "$CHANGELOG_VERSION" ] && [ -n "$PACKAGE_VERSION" ]; then if [ "$CHANGELOG_VERSION" = "$PACKAGE_VERSION" ]; then success "Versions match ($CHANGELOG_VERSION)" else warn "Version mismatch: CHANGELOG=$CHANGELOG_VERSION, package.json=$PACKAGE_VERSION" fi fi echo "" # ============================================ # 8. Check for common issues # ============================================ echo "--- Checking for Common Issues ---" # Check for duplicate sections in docs echo "Checking for duplicates in PAGES.md..." if [ -f "$DOCS_DIR/30-FRONTEND/PAGES.md" ]; then DUP_HEADERS=$(grep "^## " "$DOCS_DIR/30-FRONTEND/PAGES.md" | sort | uniq -d | wc -l) if [ "$DUP_HEADERS" -gt 0 ]; then warn "Duplicate section headers found in PAGES.md" else success "No duplicate sections in PAGES.md" fi fi # Check for TODO/FIXME in docs echo "Checking for TODO/FIXME markers..." TODO_COUNT=$(grep -r "TODO\|FIXME\|XXX" "$DOCS_DIR" --include="*.md" 2>/dev/null | wc -l || echo "0") if [ "$TODO_COUNT" -gt 0 ]; then warn "Found $TODO_COUNT TODO/FIXME markers in docs" else success "No TODO markers in docs" fi echo "" # ============================================ # Summary # ============================================ echo "========================================" echo "VERIFICATION SUMMARY" echo "========================================" echo -e "Errors: ${RED}$ERRORS${NC}" echo -e "Warnings: ${YELLOW}$WARNINGS${NC}" echo "" if [ "$ERRORS" -gt 0 ]; then echo -e "${RED}Documentation has issues that need attention!${NC}" exit 1 elif [ "$WARNINGS" -gt 0 ]; then echo -e "${YELLOW}Documentation is mostly good but has some warnings.${NC}" exit 0 else echo -e "${GREEN}Documentation verification passed!${NC}" exit 0 fi