# Rustelo Documentation System

A comprehensive, modern documentation system built with mdBook, featuring automated content generation, multiple deployment options, and seamless integration with your development workflow.

## 🎯 Overview

The Rustelo documentation system provides:

- **📚 Interactive Documentation**: Built with mdBook for beautiful, searchable docs
- **🔄 Automated Content Sync**: Automatically incorporates existing docs and info
- **🚀 Multiple Deployment Options**: GitHub Pages, Netlify, Vercel, Docker, AWS S3
- **🛠️ Developer-Friendly**: Integrated with your development workflow
- **📱 Mobile-First**: Responsive design that works everywhere
- **🔍 Full-Text Search**: Find anything across all documentation
- **🎨 Customizable**: Brand it, style it, make it yours

## 🚀 Quick Start

### 1. Setup Documentation System

```bash
# Interactive setup (recommended)
./scripts/setup-docs.sh

# Full automated setup
./scripts/setup-docs.sh --full

# Minimal setup
./scripts/setup-docs.sh --minimal
```

### 2. Start Development Server

```bash
# Start documentation development server
./scripts/docs-dev.sh

# Or using just
just docs-dev
```

### 3. Build and Deploy

```bash
# Build documentation
./scripts/build-docs.sh

# Deploy to GitHub Pages
./scripts/deploy-docs.sh github-pages

# Or using just commands
just docs-build
just docs-deploy-github
```

## 📁 System Architecture

### Directory Structure

```
template/
├── book/                    # mdBook source files
│   ├── getting-started/    # Getting started guides
│   ├── features/           # Feature documentation
│   ├── database/          # Database guides
│   ├── development/       # Development workflow
│   ├── deployment/        # Deployment guides
│   ├── api/              # API reference
│   ├── security/         # Security documentation
│   ├── troubleshooting/  # Common issues
│   ├── theme/            # Custom styling
│   ├── SUMMARY.md        # Navigation structure
│   └── introduction.md   # Main introduction
├── book-output/          # Built documentation
├── docs/                 # Technical documentation
├── info/                 # Implementation notes
├── scripts/              # Documentation scripts
│   ├── setup-docs.sh     # Setup documentation
│   ├── build-docs.sh     # Build documentation
│   ├── deploy-docs.sh    # Deploy documentation
│   └── docs-dev.sh       # Development server
├── book.toml            # mdBook configuration
└── DOCUMENTATION.md     # Documentation index
```

### Content Sources

The system automatically syncs content from:

1. **`docs/`** - Technical documentation
2. **`info/`** - Implementation details
3. **`README.md`** - Project overview
4. **`FEATURES.md`** - Feature documentation
5. **Code comments** - API documentation

## 🔧 Available Scripts

### Core Scripts

| Script | Description | Usage |
|--------|-------------|-------|
| `setup-docs.sh` | Setup documentation system | `./scripts/setup-docs.sh --full` |
| `docs-dev.sh` | Start development server | `./scripts/docs-dev.sh` |
| `build-docs.sh` | Build documentation | `./scripts/build-docs.sh` |
| `deploy-docs.sh` | Deploy documentation | `./scripts/deploy-docs.sh github-pages` |
| `generate-content.sh` | Generate dynamic content | `./scripts/generate-content.sh` |

### Script Options

#### Setup Script (`setup-docs.sh`)
```bash
./scripts/setup-docs.sh [OPTIONS]

Options:
  --full          Complete setup with all features
  --minimal       Minimal setup (just mdBook)
  --sync          Sync existing documentation
  --interactive   Interactive setup (default)
  --ci            Setup CI/CD integration
  --no-install    Skip package installation
```

#### Build Script (`build-docs.sh`)
```bash
./scripts/build-docs.sh [OPTIONS]

Options:
  --sync          Sync existing content
  --serve         Start development server
  --watch         Watch for changes
```

#### Deploy Script (`deploy-docs.sh`)
```bash
./scripts/deploy-docs.sh [PLATFORM] [OPTIONS]

Platforms:
  github-pages    Deploy to GitHub Pages
  netlify         Deploy to Netlify
  vercel          Deploy to Vercel
  aws-s3          Deploy to AWS S3
  docker          Build Docker image
  local           Serve locally

Options:
  --dry-run       Show what would be deployed
  --force         Force deployment
  --branch NAME   Deploy from specific branch
```

## 🔄 Just Commands

Integrated with the project's `justfile` for easy access:

```bash
# Documentation commands
just docs-setup          # Setup documentation system
just docs-dev            # Start development server
just docs-build          # Build documentation
just docs-build-sync     # Build with content sync
just docs-watch          # Watch for changes
just docs-deploy-github  # Deploy to GitHub Pages
just docs-deploy-netlify # Deploy to Netlify
just docs-deploy-vercel  # Deploy to Vercel
just docs-docker         # Build Docker image
just docs-generate       # Generate dynamic content
just docs-check-links    # Check for broken links
just docs-clean          # Clean build files
just docs-workflow       # Complete workflow
just help-docs           # Show documentation help
```

## 🌐 Deployment Options

### GitHub Pages
Automatic deployment via GitHub Actions:

```bash
# Setup CI/CD for GitHub Pages
./scripts/setup-docs.sh --ci

# Manual deployment
./scripts/deploy-docs.sh github-pages
```

**Features:**
- Automatic builds on push
- Custom domain support
- SSL/TLS included
- CDN distribution

### Netlify
Deploy to Netlify with optimizations:

```bash
# Deploy to Netlify
./scripts/deploy-docs.sh netlify
```

**Features:**
- Automatic builds from Git
- Preview deployments
- Custom redirects
- Performance optimizations

### Vercel
Deploy to Vercel with edge optimization:

```bash
# Deploy to Vercel
./scripts/deploy-docs.sh vercel
```

**Features:**
- Edge network deployment
- Automatic HTTPS
- Performance monitoring
- Preview deployments

### Docker
Containerized documentation:

```bash
# Build Docker image
./scripts/deploy-docs.sh docker

# Run container
docker run -p 8080:80 rustelo-docs:latest
```

**Features:**
- Nginx-based serving
- Health checks
- Security headers
- Gzip compression

### AWS S3
Static site hosting on AWS:

```bash
# Deploy to S3
export AWS_S3_BUCKET=your-bucket-name
./scripts/deploy-docs.sh aws-s3
```

**Features:**
- CloudFront integration
- Cost-effective hosting
- Global CDN
- Automatic invalidation

## 🎨 Customization

### Styling
Custom CSS and JavaScript for branding:

```css
/* book/theme/custom.css */
:root {
    --rustelo-primary: #e53e3e;
    --rustelo-secondary: #3182ce;
    --rustelo-accent: #38a169;
}

.menu-title {
    color: var(--rustelo-primary);
    font-weight: bold;
}
```

### Content Templates
Structured content generation:

```markdown
<!-- Feature documentation template -->
# Feature Name

## Overview
Brief description of the feature.

## Configuration
How to configure the feature.

## Examples
Code examples and use cases.

## Troubleshooting
Common issues and solutions.
```

### Dynamic Content
Auto-generated sections:

- **Feature Matrix**: Automatically generated feature comparison
- **Environment Variables**: Auto-extracted from code
- **API Documentation**: Generated from code comments
- **CLI Commands**: Extracted from help text

## 📊 Quality Assurance

### Automated Checks
- **Link Validation**: Broken link detection
- **Content Validation**: Ensure all sections exist
- **Style Consistency**: Formatting checks
- **Accessibility**: WCAG compliance testing

### Performance Monitoring
- **Build Times**: Track documentation build performance
- **Bundle Size**: Monitor documentation size
- **Loading Speed**: Page performance metrics
- **Search Performance**: Search functionality speed

## 🔍 Search and Navigation

### Full-Text Search
- **Instant Search**: Real-time search results
- **Keyboard Shortcuts**: `Ctrl+K` or `Cmd+K`
- **Search Highlighting**: Highlighted search terms
- **Search Suggestions**: Auto-complete functionality

### Navigation Features
- **Hierarchical Structure**: Logical content organization
- **Breadcrumbs**: Navigation context
- **Previous/Next**: Sequential navigation
- **Table of Contents**: Section overview
- **Mobile Navigation**: Touch-friendly mobile nav

## 🤖 CI/CD Integration

### GitHub Actions Workflow
Automatic documentation builds and deployments:

```yaml
# .github/workflows/docs.yml
name: Build and Deploy Documentation

on:
  push:
    branches: [ main ]
    paths:
      - 'book/**'
      - 'docs/**'
      - 'info/**'

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup Rust
        uses: actions-rs/toolchain@v1
      - name: Build Documentation
        run: ./scripts/build-docs.sh
      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
```

### Features
- **Automated Builds**: Build on every push
- **Link Checking**: Validate all links
- **Multi-format Output**: HTML, PDF, EPUB
- **Deployment**: Automatic deployment to hosting
- **Notifications**: Build status notifications

## 📱 Mobile Experience

### Responsive Design
- **Mobile-First**: Optimized for mobile devices
- **Touch Navigation**: Swipe gestures and touch controls
- **Fast Loading**: Optimized for mobile connections
- **Offline Support**: Progressive web app features

### Performance
- **Lazy Loading**: Load content as needed
- **Image Optimization**: Optimized images for mobile
- **Caching Strategy**: Smart caching for offline use
- **Compression**: Gzip compression for faster loading

## 🔐 Security

### Security Headers
- **Content Security Policy**: XSS protection
- **X-Frame-Options**: Clickjacking protection
- **X-Content-Type-Options**: MIME type sniffing protection
- **Referrer Policy**: Control referrer information

### Access Control
- **Authentication**: Optional authentication for private docs
- **Authorization**: Role-based access control
- **IP Restrictions**: Restrict access by IP
- **Rate Limiting**: Prevent abuse

## 📈 Analytics

### Usage Analytics
- **Page Views**: Track popular documentation sections
- **Search Analytics**: Most searched terms
- **User Journey**: How users navigate documentation
- **Performance Metrics**: Page load times and optimization

### Build Analytics
- **Build Times**: Monitor documentation build performance
- **Content Growth**: Track documentation growth over time
- **Link Health**: Monitor broken links
- **Quality Metrics**: Content quality indicators

## 🛠️ Development Workflow

### Local Development
```bash
# Start development server
just docs-dev

# Make changes to book/ directory
# Changes auto-reload in browser

# Build for production
just docs-build
```

### Content Creation
1. **Write Content**: Create/edit markdown files in `book/`
2. **Preview Changes**: Use development server
3. **Build Documentation**: Generate static files
4. **Deploy**: Push to hosting platform

### Collaboration
- **Git Integration**: Version control for documentation
- **Pull Requests**: Review documentation changes
- **Issue Tracking**: Track documentation improvements
- **Contributor Guidelines**: Clear contribution process

## 🔄 Content Management

### Content Sources
- **Existing Documentation**: Sync from `docs/` and `info/`
- **Code Comments**: Extract API documentation
- **Configuration Files**: Document configuration options
- **Examples**: Include code examples

### Content Generation
- **Dynamic Content**: Auto-generated sections
- **Cross-References**: Automatic link generation
- **Content Templates**: Consistent formatting
- **Validation**: Ensure content completeness

## 🚀 Performance

### Build Performance
- **Incremental Builds**: Only rebuild changed content
- **Parallel Processing**: Multi-threaded builds
- **Caching**: Cache build artifacts
- **Optimization**: Minimize build times

### Runtime Performance
- **Fast Loading**: Optimized for speed
- **Search Performance**: Instant search results
- **Mobile Performance**: Optimized for mobile
- **CDN Integration**: Global content delivery

## 🎯 Best Practices

### Content Writing
- **Clear Writing**: Use simple, clear language
- **Code Examples**: Include working examples
- **Visual Aids**: Screenshots and diagrams
- **Cross-References**: Link related content

### Organization
- **Logical Structure**: Organize content logically
- **Consistent Formatting**: Use consistent styles
- **Navigation**: Make content easy to find
- **Maintenance**: Keep content up-to-date

### Performance
- **Optimize Images**: Compress images for web
- **Minimize JavaScript**: Keep JavaScript minimal
- **Efficient CSS**: Use efficient CSS selectors
- **Caching**: Implement proper caching

## 🆘 Troubleshooting

### Common Issues

**mdBook not found:**
```bash
# Install mdBook
cargo install mdbook
```

**Build fails:**
```bash
# Clean and rebuild
just docs-clean
just docs-build
```

**Links not working:**
```bash
# Check for broken links
just docs-check-links
```

**Deployment fails:**
```bash
# Check deployment logs
./scripts/deploy-docs.sh github-pages --dry-run
```

### Getting Help
- **Documentation**: Check this documentation
- **Issues**: Report issues on GitHub
- **Discussions**: Join community discussions
- **Support**: Get help from maintainers

## 🎉 Conclusion

The Rustelo documentation system provides a comprehensive, modern solution for project documentation. With automated content generation, multiple deployment options, and seamless integration with your development workflow, it makes maintaining high-quality documentation effortless.

### Key Benefits
- **Comprehensive**: Covers all aspects of documentation
- **Automated**: Minimal manual maintenance required
- **Flexible**: Adapts to your project needs
- **Modern**: Built with current best practices
- **Scalable**: Grows with your project

### Getting Started
1. Run `./scripts/setup-docs.sh --full`
2. Start developing with `./scripts/docs-dev.sh`
3. Deploy with `./scripts/deploy-docs.sh github-pages`

**Happy documenting!** 📚✨

---

*For the latest documentation, visit: [https://yourusername.github.io/rustelo](https://yourusername.github.io/rustelo)*