Documentation DeploymentΒΆ

This Tutorial covers different options for deploying the ToolUniverse documentation.

Quick StartΒΆ

Build and serve documentation locally:

cd docs/
./build_docs.sh
./validate_docs.sh

The validation script will offer to start a local server at http://localhost:8080.

GitHub PagesΒΆ

Automated DeploymentΒΆ

The repository includes GitHub Actions workflow for automatic deployment to GitHub Pages.

Setup Steps:

  1. Enable GitHub Pages in repository settings:

    • Go to repository Settings > Pages

    • Set source to GitHub Actions

  2. Push to main branch - documentation will build automatically

  3. Access documentation at: https://yourusername.github.io/ToolUniverse/

Manual DeploymentΒΆ

For manual GitHub Pages deployment:

# Build documentation
cd docs/
./build_docs.sh

# Copy to gh-pages branch
git checkout --orphan gh-pages
git rm -rf .
cp -r docs/_build/html/* .
git add .
git commit -m "Deploy documentation"
git push -f origin gh-pages

ReadTheDocsΒΆ

Automated SetupΒΆ

  1. Connect repository to ReadTheDocs:

  2. Configuration file .readthedocs.yaml is already provided

  3. Documentation builds automatically on commits

ConfigurationΒΆ

The .readthedocs.yaml file specifies:

  • Python version: 3.8+

  • Requirements: docs/requirements.txt

  • Sphinx configuration: docs/conf.py

  • Output formats: HTML, PDF

Local Development ServerΒΆ

Development with Auto-reloadΒΆ

Use sphinx-autobuild for live reloading during development:

# Install if not already installed
pip install sphinx-autobuild

# Start development server
cd docs/
sphinx-autobuild . _build/html --port 8080

The server will automatically rebuild when files change.

Production ServerΒΆ

For production hosting, use a proper web server:

Nginx example:

server {
    listen 80;
    server_name docs.yourdomain.com;
    root /path/to/ToolUniverse/docs/_build/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

Apache example:

<VirtualHost *:80>
    ServerName docs.yourdomain.com
    DocumentRoot /path/to/ToolUniverse/docs/_build/html
    DirectoryIndex index.html
</VirtualHost>

Docker DeploymentΒΆ

Dockerfile for NginxΒΆ

Create Dockerfile in docs directory:

FROM nginx:alpine
COPY _build/html /usr/share/nginx/html
EXPOSE 80

Build and run:

cd docs/
./build_docs.sh
docker build -t tooluniverse-docs .
docker run -p 8080:80 tooluniverse-docs

Multi-stage BuildΒΆ

For smaller images with build included:

# Build stage
FROM python:3.9-slim as builder
WORKDIR /docs
COPY . .
RUN pip install -r requirements.txt && \
    sphinx-build -b html . _build/html

# Serve stage
FROM nginx:alpine
COPY --from=builder /docs/_build/html /usr/share/nginx/html
EXPOSE 80

Continuous IntegrationΒΆ

GitHub ActionsΒΆ

The .github/workflows/docs.yml workflow:

  • Triggers: Push to main, pull requests

  • Builds: HTML and PDF documentation

  • Deploys: To GitHub Pages (on main branch)

  • Tests: Link checking, validation

View workflow status in repository Actions tab.

Custom CI/CDΒΆ

For other CI systems, use these commands:

# Install dependencies
pip install -r docs/requirements.txt

# Build documentation
cd docs/
sphinx-build -b html . _build/html

# Validate build
./validate_docs.sh

# Deploy (custom logic)
./deploy.sh

TroubleshootingΒΆ

Common IssuesΒΆ

Build fails with module import errors:

# Install project in editable mode
pip install -e .
cd docs/
./build_docs.sh

Missing static files:

# Clean and rebuild
cd docs/
make clean
./build_docs.sh

Broken links:

# Check with sphinx-build
sphinx-build -b linkcheck . _build/linkcheck

Permission errors on deployment:

# Fix file permissions
chmod +x docs/*.sh

Performance OptimizationΒΆ

For large documentation sites:

  1. Enable parallel builds:

    # In conf.py
    numjobs = 4  # Use multiple processes
    
  2. Optimize images:

    # Compress images in _static/
    find _static/ -name "*.png" -exec optipng {} \;
    
  3. Use CDN for static files:

    # In conf.py
    html_baseurl = 'https://cdn.yourdomain.com/'
    

MonitoringΒΆ

Health ChecksΒΆ

Create a simple health check endpoint:

# Check if documentation is accessible
curl -f https://yourdocs.com/ || exit 1

AnalyticsΒΆ

Add Google Analytics to conf.py:

html_theme_options = {
    'analytics_id': 'UA-XXXXXXX-1',
}

Or add custom tracking code to _templates/layout.html. yi cxi Backup and Recovery β€”β€”β€”β€”β€”β€”-

Backup StrategyΒΆ

  1. Source control: Documentation source in Git

  2. Built artifacts: Archive built documentation

  3. Dependencies: Pin versions in requirements.txt

# Create backup
tar -czf docs-backup-$(date +%Y%m%d).tar.gz _build/

RecoveryΒΆ

# Restore from backup
tar -xzf docs-backup-20231201.tar.gz

# Or rebuild from source
./build_docs.sh

This completes the deployment configuration. The documentation system now supports multiple deployment targets with automated CI/CD integration.