This GitHub Action uses patchwork-cli to automatically document methods in your code by generating docstrings.
- Automatically generates docstrings for methods in your code
- Supports various LLM providers (OpenAI, local models, or custom endpoints)
- Creates pull requests with the generated docstrings
- Option to rewrite existing docstrings
- Configurable base path for code scanning
- Customizable branch naming and PR behavior
name: Generate Docstrings
on:
workflow_dispatch: # Allow manual triggers
jobs:
generate-docstrings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: patched-codes/[email protected]
with:
patched_api_key: ${{ secrets.PATCHED_API_KEY }}
base_path: "./src" # Path to start generating docstrings from
One of the following must be provided:
patched_api_key
: Patched API key for the LLM (Get an API key)openai_api_key
: OpenAI API key for the LLM (Get an API key)
base_path
: Base path to start generating docstrings from (default: './')github_token
: GitHub token for creating pull requests (default: Automatically set by GitHub)model
: LLM model to useclient_base_url
: Base URL for the LLM APIrewrite_existing
: Whether to rewrite existing docstringsbranch_prefix
: Prefix for the created branch (default: 'patched-generate-docstring/')disable_branch
: Disable creating new branchesdisable_pr
: Disable creating pull requestsforce_pr_creation
: Force push commits to existing PRmodel_temperature
: Temperature parameter for the LLMmodel_top_p
: Top-p parameter for the LLMmodel_max_tokens
: Maximum tokens for the LLM response
- uses: patched-codes/[email protected]
with:
patched_api_key: ${{ secrets.PATCHED_API_KEY }}
base_path: "./src"
- uses: patched-codes/[email protected]
with:
patched_api_key: ${{ secrets.PATCHED_API_KEY }}
base_path: "./src"
rewrite_existing: true
branch_prefix: "docs/auto-docstrings/"
- uses: patched-codes/[email protected]
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
base_path: "./src"
model: "gpt-4"
model_temperature: 0.2
model_top_p: 0.95
model_max_tokens: 2000
MIT
Contributions are welcome! Please feel free to submit a Pull Request.