Prerequisites
Before starting, make sure you have:- DocuGen AI installed (see Installation)
- A Gemini API key configured in your environment
- A Python project to document
Basic Usage
The primary command for generating documentation isdocugen generate. Let’s start with the simplest example.
Run the generate command
- Scan all Python files in the current directory
- Parse the code structure using AST analysis
- Generate documentation using Gemini AI
- Save the output to
README.md
DocuGen AI respects
.gitignore rules and automatically excludes common directories like venv/, __pycache__/, and .git/.Command Line Options
Thegenerate command supports several options for customization:
Path Argument
Path to the Python project to analyze. Can be an absolute or relative path.
Output Option
Output Markdown file name. Can be a filename or a relative/absolute path.
Model Option
Gemini model name to use for generation. Different models offer different capabilities and pricing.
Prompt Option
Optional additional instruction to guide the AI in generating specific content or emphasizing certain aspects.
Config Option
Optional TOML configuration file path for advanced settings.
Complete Working Example
Let’s generate documentation for a Python package with custom settings:Understanding the Output
When you run thegenerate command, you’ll see status messages indicating progress:
- Project Overview: High-level description of what the project does
- Technical Architecture: Explanation of the code structure
- Key Features: Main capabilities extracted from the code
- API Reference: Documentation of classes, functions, and methods
- Usage Examples: Code snippets showing how to use the project
Step-by-Step Tutorial
Let’s document a sample Python project from scratch:Run DocuGen AI
- Scans your Python files
- Parses the AST structure
- Calls the Gemini API
- Generates professional documentation
Common Use Cases
Document a specific module
Document a specific module
Update existing documentation
Update existing documentation
Generate documentation for multiple projects
Generate documentation for multiple projects
CI/CD Integration
CI/CD Integration
Add to your GitHub Actions workflow:
.github/workflows/docs.yml
Troubleshooting
Error: Missing GEMINI_API_KEY
Error: Missing GEMINI_API_KEY
Problem: The API key is not configured.Solution:Or create a
.env file with:Error: No Python files found
Error: No Python files found
Problem: DocuGen AI couldn’t find any Python files in the specified path.Solution:
- Verify the path is correct:
ls /path/to/project - Ensure the directory contains
.pyfiles - Check that files aren’t excluded by
.gitignore
Error: Project path does not exist
Error: Project path does not exist
Problem: The specified path is invalid.Solution:
Error: Gemini API call failed
Error: Gemini API call failed
Problem: Communication with the Gemini API failed.Solution:
- Verify your API key is valid
- Check your internet connection
- Ensure you have API quota remaining
- Try a different model:
--model gemini-pro
Next Steps
CLI Reference
Explore all available commands and options
Configuration
Learn about advanced configuration options
Core Concepts
Understand how DocuGen AI works internally
API Reference
Detailed API documentation for the DocuGen AI library
