generate_docs.sh
1 #!/bin/bash 2 # Generate API documentation 3 4 # Exit on error 5 set -e 6 7 # Set environment variables 8 export PYTHONPATH=$PWD 9 10 # Check if virtual environment exists 11 if [ ! -d "venv" ]; then 12 echo "Error: Virtual environment not found. Please run setup.py first." 13 exit 1 14 fi 15 16 # Activate virtual environment 17 if [ -f "venv/bin/activate" ]; then 18 source venv/bin/activate 19 else 20 source venv/Scripts/activate 21 fi 22 23 # Install documentation dependencies 24 pip install -r requirements/dev.txt 25 26 # Generate OpenAPI schema 27 echo "Generating OpenAPI schema..." 28 python -c " 29 import uvicorn 30 import json 31 from sussro_services.main import app 32 33 # Generate OpenAPI schema 34 openapi_schema = app.openapi() 35 36 # Save to file 37 with open('openapi.json', 'w') as f: 38 json.dump(openapi_schema, f, indent=2) 39 " 40 41 echo "OpenAPI schema generated at: $PWD/openapi.json" 42 43 # Build MkDocs documentation 44 echo "\nBuilding documentation with MkDocs..." 45 mkdocs build --clean 46 47 echo "\nDocumentation built in the 'site' directory." 48 echo "You can view it by opening 'site/index.html' in your browser." 49 echo "\nTo serve the documentation locally, run: mkdocs serve"