AI-powered documentation generator for Python projects using OpenAI
Project description
AI Documentation Generator ๐ค๐
Automatically generate comprehensive documentation for your Python projects using OpenAI's GPT models. This tool analyzes your codebase and creates detailed, well-structured documentation that helps developers understand and use your code effectively.
โจ Features
- ๐ Intelligent Code Analysis: Uses AST parsing to understand your code structure
- ๐ Comprehensive Documentation: Generates detailed docs for modules, classes, functions, and more
- ๐ Incremental Updates: Only regenerates docs for files that have changed
- ๐ง Git Integration: Tracks changes through git history
- ๐ฐ Cost-Effective: Minimal API usage through smart caching and incremental updates
- ๐จ Beautiful Output: Generates well-structured Markdown documentation
- โ๏ธ Highly Configurable: Customize what gets documented and how
- ๐ฅ๏ธ CLI & API: Use as a command-line tool or integrate into your Python projects
๐ฆ Installation
pip install ai-doc-generator
Or install from source:
git clone https://github.com/haseebrj17/ai-doc-generator.git
cd ai-doc-generator
pip install -e .
๐ Quick Start
- Set your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"
- Generate documentation for your project:
ai-doc-gen /path/to/your/project
That's it! Your documentation will be generated in docs/generated/.
๐ Usage
Command Line Interface
# Generate docs for current directory
ai-doc-gen
# Generate docs for specific path
ai-doc-gen /path/to/project
# Force full regeneration (ignore cache)
ai-doc-gen --full
# Use a specific model
ai-doc-gen --model gpt-4o-mini
# Custom output directory
ai-doc-gen --output docs/api
# Include test files
ai-doc-gen --include-tests
# Dry run to see what would be documented
ai-doc-gen --dry-run
Python API
from ai_doc_generator import Config, DocumentationGenerator
# Create configuration
config = Config(
project_root="./my_project",
output_dir="./docs",
include_tests=False,
model="gpt-4o"
)
# Generate documentation
generator = DocumentationGenerator(config)
generator.generate_documentation()
โ๏ธ Configuration
Create a ai-doc-config.json file in your project root:
{
"model": "gpt-4o",
"output_dir": "docs/generated",
"include_patterns": ["*.py"],
"exclude_dirs": ["tests", "__pycache__", ".venv"],
"exclude_files": ["setup.py"],
"max_file_size": 100000,
"include_tests": false
}
๐ธ Cost Estimation
For a typical Python project:
- Small project (10k lines): ~$2-3
- Medium project (50k lines): ~$8-12
- Large project (100k lines): ~$15-25
After initial generation, incremental updates cost 90% less!
๐ Output Structure
docs/generated/
โโโ README.md # Main documentation index
โโโ project-overview.md # High-level project analysis
โโโ api-reference.md # Complete API reference
โโโ modules/ # Module-specific documentation
โ โโโ core/
โ โโโ utils/
โ โโโ ...
โโโ documentation.json # Raw documentation data
๐ ๏ธ Advanced Features
Incremental Documentation
Only regenerate documentation for files that have changed:
# First run - documents everything
ai-doc-gen
# Subsequent runs - only changed files
ai-doc-gen
Custom Prompts
Customize the documentation style:
config = Config(
system_prompt="Generate concise API documentation focusing on usage examples..."
)
Multiple Models
Use different models for different purposes:
gpt-4o: Best quality, detailed documentationgpt-4o-mini: Faster and cheaper, good for most projectsgpt-4-turbo-preview: Balance of quality and cost
๐งช Development
# Clone the repository
git clone https://github.com/haseebrj17/ai-doc-generator.git
cd ai-doc-generator
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
black .
flake8 .
mypy .
# Run tests with coverage
pytest --cov=ai_doc_generator
๐ Documentation
The project documentation is available at: https://haseebrj17.github.io/ai-doc-generator/
Setting up GitHub Pages
- Go to Settings โ Pages in your GitHub repository
- Under "Build and deployment", select "Deploy from a branch"
- Choose
gh-pagesbranch and/ (root)folder - Click Save
๐ Publishing to PyPI
This project has automated publishing workflows:
Automatic Publishing
When you push changes to main with an updated version in pyproject.toml, the package will automatically be published to PyPI if all tests pass.
Manual Publishing
- Create a new tag:
git tag v1.0.1 && git push origin v1.0.1 - The workflow will automatically publish to PyPI
Setting up PyPI Tokens
- Create an account on PyPI
- Generate an API token from your account settings
- Add the token as
PYPI_API_TOKENin your repository secrets (Settings โ Secrets โ Actions) - Optionally, add
TEST_PYPI_API_TOKENfor test releases
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- OpenAI for providing the GPT models
- The Python AST module for code analysis
- All contributors and users of this project
๐ Support
- ๐ง Email: muhamadhaseeb2001@gmail.com
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
Made with โค๏ธ by Muhammad Haseeb
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_doc_generator-1.0.1.tar.gz.
File metadata
- Download URL: ai_doc_generator-1.0.1.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58531f36798c6a1793768332b52a6f41c328dc96bcec3f2e42fce064a0140654
|
|
| MD5 |
4e4f84e8390953d972210ad2b882ee40
|
|
| BLAKE2b-256 |
44eeedb1804d1bfa5ad664bff544e055e3912f8f226320b50f483b699d64dd51
|
File details
Details for the file ai_doc_generator-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ai_doc_generator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50f9b113c613869b723fe2f07d255d84f7ede3a6a943907a52a1ece2645e6a81
|
|
| MD5 |
6fb2e7204503be5849fd4ed4b864081b
|
|
| BLAKE2b-256 |
d6cbb88caecaba3e4b701c790b75b5cd281913586f14846d7e17a0e0faf3f414
|