Skip to main content

Quick Start Examples

Basic Documentation Generation

Generate documentation for the current directory:
docugen generate .
This creates README.md in the current directory with complete documentation of your Python project.

Generate for Specific Directory

Analyze a specific source directory:
docugen generate ./src
docugen generate /path/to/project

Output Customization

Custom Output Filename

# Generate DOCUMENTATION.md instead of README.md
docugen generate . --output DOCUMENTATION.md

Model Selection

Using Different Gemini Models

Choose the appropriate model based on your needs:
# Fastest generation with gemini-3.1-flash-lite-preview
docugen generate .
Model Recommendations:
  • Use gemini-3.1-flash-lite-preview for quick iterations and large projects
  • Use gemini-pro for production documentation with good balance
  • Use gemini-ultra for critical, public-facing documentation where quality is paramount

Custom AI Instructions

Using the —prompt Option

Customize the AI’s focus with additional instructions:
# Emphasize security aspects
docugen generate . \
  --prompt "Focus on security best practices and potential vulnerabilities"

Configuration-Based Workflows

Using TOML Configuration Files

Setup:Create .docugen.toml in your project root:
model = "gemini-pro"
output = "docs/README.md"
Usage:
# Automatically uses .docugen.toml settings
cd /path/to/project
docugen generate .
Result:
  • Uses gemini-pro model
  • Outputs to docs/README.md
  • Settings are committed with the project

Environment-Based Workflows

Managing API Keys

# Set API key for current session
export GEMINI_API_KEY="your-api-key-here"
docugen generate .

Real-World Use Cases

Use Case 1: Open Source Project

Scenario: Maintain up-to-date README for a public GitHub repository. Setup:
# Project structure
my-oss-project/
├── .env.example          # Template for contributors
├── .docugen.toml         # Shared configuration
├── .gitignore            # Excludes .env
└── src/
.docugen.toml:
model = "gemini-pro"
output = "README.md"
.env.example:
GEMINI_API_KEY=your-key-here
Workflow:
# First time setup
cp .env.example .env
# Edit .env with your actual API key

# Generate/update documentation after code changes
docugen generate ./src --prompt "Emphasize contribution guidelines"

# Commit the updated README (not .env!)
git add README.md .docugen.toml .env.example
git commit -m "Update documentation"

Use Case 2: Multi-Module Project

Scenario: Generate separate documentation for different modules. Project structure:
monorepo/
├── api/
├── core/
├── utils/
└── docs/
Workflow:
# Document each module separately
docugen generate ./api \
  --output docs/API.md \
  --prompt "Focus on REST endpoints and authentication"

docugen generate ./core \
  --output docs/CORE.md \
  --prompt "Explain core business logic and data models"

docugen generate ./utils \
  --output docs/UTILS.md \
  --prompt "Provide utility function reference"

Use Case 3: CI/CD Integration

Scenario: Automatically update documentation on each commit. GitHub Actions (.github/workflows/docs.yml):
name: Update Documentation

on:
  push:
    branches: [main]
    paths:
      - '**.py'

jobs:
  generate-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      
      - name: Install DocuGen
        run: pip install docugen-ai
      
      - name: Generate Documentation
        env:
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
        run: |
          docugen generate ./src \
            --output README.md \
            --model gemini-pro
      
      - name: Commit Documentation
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add README.md
          git diff --quiet && git diff --staged --quiet || \
            (git commit -m "docs: auto-update README [skip ci]" && git push)
Store your GEMINI_API_KEY as a GitHub secret, never commit it to the repository.

Use Case 4: Documentation Profiles

Scenario: Generate different documentation styles for different audiences. Setup multiple config files:
project/
├── configs/
│   ├── docs-internal.toml
│   ├── docs-external.toml
│   └── docs-api.toml
└── src/
configs/docs-internal.toml:
model = "gemini-pro"
output = "docs/INTERNAL.md"
configs/docs-external.toml:
model = "gemini-ultra"
output = "README.md"
configs/docs-api.toml:
model = "gemini-pro"
output = "docs/API_REFERENCE.md"
Workflow:
# Generate internal documentation
docugen generate ./src \
  --config configs/docs-internal.toml \
  --prompt "Include implementation details and TODOs"

# Generate external documentation
docugen generate ./src \
  --config configs/docs-external.toml \
  --prompt "Focus on features and getting started"

# Generate API reference
docugen generate ./src \
  --config configs/docs-api.toml \
  --prompt "Detailed API reference with all parameters"

Performance Tips

Use Flash Model

For large projects, use gemini-3.1-flash-lite-preview (default) for faster generation:
docugen generate ./large-project

Target Specific Directories

Instead of scanning everything, target specific source directories:
docugen generate ./src
# Rather than: docugen generate .

Use .gitignore

DocuGen respects .gitignore patterns, so keep it updated to skip unnecessary files automatically.

Cache Results

In CI/CD, cache generated docs and only regenerate when Python files change:
paths:
  - '**.py'

Common Patterns

Pattern 1: Quick Iteration

# Fast feedback loop during development
while true; do
  # Make code changes
  docugen generate ./src --output /tmp/preview.md
  # Review /tmp/preview.md
  read -p "Generate again? (y/n) " -n 1 -r
  echo
  [[ $REPLY =~ ^[Yy]$ ]] || break
done

Pattern 2: Multi-Language Output

# English version
docugen generate ./src \
  --output README.md \
  --prompt "Write in English"

# Spanish version
docugen generate ./src \
  --output README.es.md \
  --prompt "Write in Spanish (Español)"

# French version
docugen generate ./src \
  --output README.fr.md \
  --prompt "Write in French (Français)"

Pattern 3: Staged Documentation

# Phase 1: Quick draft with fast model
docugen generate ./src \
  --output docs/DRAFT.md \
  --model gemini-3.1-flash-lite-preview

# Review draft...

# Phase 2: Refined version with better model
docugen generate ./src \
  --output README.md \
  --model gemini-ultra \
  --prompt "Polish language and add comprehensive examples"

Troubleshooting Common Issues

Error: No Python files found to analyze.Solutions:
  1. Verify you’re pointing to the correct directory:
    ls ./path/to/project/*.py
    
  2. Check that Python files aren’t being excluded by .gitignore
  3. Use absolute paths if relative paths aren’t working:
    docugen generate /full/path/to/project
    
Error: Missing GEMINI_API_KEYQuick fix:
# Set for current session
export GEMINI_API_KEY="your-key"

# Or create .env file
echo 'GEMINI_API_KEY=your-key' > .env
See Configuration for detailed setup.
Issue: Generated file is not where you expected.Check:
  1. Relative paths are relative to the project directory, not current directory:
    # If you run: docugen generate ./src -o docs/README.md
    # Output will be: ./src/docs/README.md
    
  2. Use absolute paths for precise control:
    docugen generate ./src -o "$(pwd)/docs/README.md"
    
Issue: Documentation takes a long time to generate.Solutions:
  1. Use the faster model:
    docugen generate . --model gemini-3.1-flash-lite-preview
    
  2. Target only necessary directories:
    docugen generate ./src  # Instead of entire project
    
  3. Check your internet connection (API calls require network)

Next Steps

CLI Reference

Complete reference of all CLI commands and options

Configuration

Detailed guide to configuration files and environment variables

API Reference

Dive into the Python API for programmatic usage

Core Concepts

Understand how DocuGen works under the hood

Build docs developers (and LLMs) love