Auto Documentation & Docstrings
ActionsAbout
Tags
Β (2)A GitHub Action that automatically generates comprehensive documentation and docstrings for multi-language codebases using AI models (Anthropic Claude or Google Gemini).
- Multi-language Support: Works with Go, TypeScript, Python and Java. Easily extensible to other languages.
- AI-Powered: Uses either Anthropic Claude or Google Gemini for intelligent documentation generation
- Automatic Detection: Scans your codebase and identifies files that need documentation
- Smart Documentation: Generates appropriate docstrings following language-specific conventions
- Repository Analysis: Creates an AI_CONTEXT.md file with comprehensive project context
- Pull Request Workflow: Creates a new branch with documentation changes for review
| Language | Documentation Style | Features |
|---|---|---|
| Go | // FunctionName does... |
Exported functions, parameters, return values |
| TypeScript | /** @description */ TSDoc |
Functions, classes, interfaces with JSDoc tags |
| Python | """Triple quotes""" |
Functions and classes with Google/NumPy style |
| Java | /** Javadoc */ |
Public methods and classes with Javadoc tags |
You'll need an API key from either:
- Anthropic Claude: Get your API key from Anthropic Console
- Google Gemini: Get your API key from Google AI Studio
Add your chosen API key to your repository secrets:
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# OR
GEMINI_API_KEY=your_gemini_api_key_here
name: Auto Documentation
on:
push:
branches: [main, develop]
pull_request:
types: [opened, synchronize]
jobs:
documentation:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Auto Documentation & Docstrings
uses: devasy23/auto-documentation-action@v1
with:
model_provider: 'anthropic'
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - name: Auto Documentation & Docstrings
uses: devasy23/auto-documentation-action@v1
with:
model_provider: 'gemini'
gemini_api_key: ${{ secrets.GEMINI_API_KEY }} - name: Auto Documentation & Docstrings
uses: devasy23/auto-documentation-action@v1
with:
model_provider: 'anthropic'
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
target_branches: 'main,master,develop,staging'
commit_message: 'docs: Update documentation with AI assistance'name: Auto Documentation
on:
workflow_dispatch:
inputs:
model_provider:
description: 'AI Model Provider'
required: true
default: 'anthropic'
type: choice
options:
- anthropic
- gemini
jobs:
documentation:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Auto Documentation & Docstrings
uses: devasy23/auto-documentation-action@v1
with:
model_provider: ${{ github.event.inputs.model_provider }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}| Input | Description | Required | Default |
|---|---|---|---|
model_provider |
AI model provider (anthropic or gemini) |
No | anthropic |
anthropic_api_key |
Anthropic API key for Claude AI | No* | - |
gemini_api_key |
Google Gemini API key | No* | - |
target_branches |
Comma-separated list of branches to run on | No | main,master,develop |
commit_message |
Custom commit message for documentation updates | No | docs: Auto-generated multi-language documentation |
*Required based on selected model_provider
| Output | Description |
|---|---|
files_processed |
Number of files that were processed |
context_md_generated |
Whether AI_CONTEXT.md was generated (true/false) |
branch_created |
Name of the branch created with changes |
This action is designed to be easily extensible to support new languages. To add support for a new language, you need to create a new JSON configuration file in the config directory.
For example, to add support for a new language called "MyLang", you would create a file named config/mylang.json with the following structure:
{
"language": "MyLang",
"extensions": ["mylang"],
"detection_logic": {
"definitions": "regex_to_find_definitions",
"documented": "regex_to_find_documented_definitions"
},
"prompt": [
"Prompt to generate documentation for MyLang..."
]
}language: The name of the language.extensions: An array of file extensions for the language.detection_logic:definitions: A regular expression to find the total number of definitions (functions, classes, etc.) in a file.documented: A regular expression to find the number of already documented definitions.
prompt: An array of strings that will be joined to form the prompt for the AI model.
The action will automatically pick up the new configuration file and start processing files for the new language.
- Repository Analysis: Scans your codebase structure and creates a comprehensive AI_CONTEXT.md file
- File Detection: Identifies Go, TypeScript, and Python files that lack proper documentation
- AI Documentation: Uses your chosen AI provider to generate appropriate docstrings and comments
- Quality Validation: Ensures generated content follows language-specific conventions
- Branch Creation: Creates a new branch with all documentation changes
- Summary Report: Provides a detailed summary of what was processed and updated
The action automatically creates an AI_CONTEXT.md file containing:
- Project Overview: Intelligent analysis of your project's purpose
- Architecture: Inferred structure and design patterns
- Technology Stack: Detected languages, frameworks, and tools
- Development Guidelines: Language-specific best practices
- Build Instructions: Appropriate commands for your project type
- Testing Strategy: Recommended testing approaches
- API keys are handled securely through GitHub Secrets
- All AI API calls are made over HTTPS
- No code is stored or cached by the AI providers beyond the request
- Generated documentation is reviewed before merging via pull request workflow
API Key Not Working
- Ensure your API key is correctly added to repository secrets
- Verify the API key has proper permissions and isn't expired
- Check that you're using the correct provider (
anthropicvsgemini)
No Files Processed
- The action only processes files with undocumented exported functions/classes
- Ensure your code follows standard conventions for exports
- Check the action logs for detailed file scanning results
Generated Content Issues
- AI-generated content is validated but may occasionally need manual review
- The action creates a review branch specifically for this purpose
- You can adjust prompts by modifying the action workflow
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Auto Documentation & Docstrings is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.