AI-powered docstring generator for Python codebases. Batch-generates Google, NumPy, or Sphinx docstrings. Preserves existing docs. CI-ready.
Project description
docstring-ai
AI-powered docstring generator for Python codebases. Batch-generates Google, NumPy, or Sphinx docstrings. Preserves existing docs. CI-ready.
Install
pip install docstring-ai
Requires ANTHROPIC_API_KEY.
Quick start
from docstring_ai import DocstringAI
ai = DocstringAI(style="google")
# Single function
result = ai.generate_for_source("""
def compute_recall(retrieved: list, relevant: list, k: int = 5) -> float:
hits = sum(1 for r in retrieved[:k] if r in relevant)
return hits / len(relevant) if relevant else 0.0
""")
print(result.docstring)
# Entire file
report = ai.process_file("mymodule.py", dry_run=True)
print(report.summary())
# Generated: 8 / Already had: 3 / Skipped: 2
# Entire directory
reports = ai.process_directory("src/", pattern="*.py")
Styles
DocstringAI(style="google") # Google (default)
DocstringAI(style="numpy") # NumPy
DocstringAI(style="sphinx") # Sphinx / reST
CLI
docstring-ai src/mymodule.py --dry-run
docstring-ai src/ --style numpy
docstring-ai src/ --overwrite --include-private
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 docstring_ai-1.0.0.tar.gz.
File metadata
- Download URL: docstring_ai-1.0.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56c17a76324ccc9fbcd1f8e617e1d7189b12aa90ff558dcf6cbaaebd288f7b09
|
|
| MD5 |
3f5a0080727f7672584eeccaaf7f60cd
|
|
| BLAKE2b-256 |
f1ce77223de9782162a938fd231a78dc510f36d33b56546bb1f7fd2a427669bd
|
Provenance
The following attestation bundles were made for docstring_ai-1.0.0.tar.gz:
Publisher:
publish.yml on obielin/docstring-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docstring_ai-1.0.0.tar.gz -
Subject digest:
56c17a76324ccc9fbcd1f8e617e1d7189b12aa90ff558dcf6cbaaebd288f7b09 - Sigstore transparency entry: 1281886777
- Sigstore integration time:
-
Permalink:
obielin/docstring-ai@f54ae6e2c79e55719137995f7656b581dfb1fff2 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/obielin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f54ae6e2c79e55719137995f7656b581dfb1fff2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file docstring_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: docstring_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6570099cc1faa886d5cff96312edd22959f71d57693f78ac58ef32cef61794a0
|
|
| MD5 |
8c541187f9359477a06427bcf609b328
|
|
| BLAKE2b-256 |
6a752aa6786f9a9434d74ce6640696cf45e41d9f1e01419bc2c3d0ee95e006e3
|
Provenance
The following attestation bundles were made for docstring_ai-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on obielin/docstring-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docstring_ai-1.0.0-py3-none-any.whl -
Subject digest:
6570099cc1faa886d5cff96312edd22959f71d57693f78ac58ef32cef61794a0 - Sigstore transparency entry: 1281886837
- Sigstore integration time:
-
Permalink:
obielin/docstring-ai@f54ae6e2c79e55719137995f7656b581dfb1fff2 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/obielin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f54ae6e2c79e55719137995f7656b581dfb1fff2 -
Trigger Event:
release
-
Statement type: