Skip to main content

docstring-ai

AI-powered docstring generator for Python codebases. Batch-generates Google, NumPy, or Sphinx docstrings. Preserves existing docs. CI-ready.

Tests Python License LinkedIn

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

Linda Oraegbunam | LinkedIn | GitHub

Release files for docstring-ai 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docstring-ai 1.0.0
File Size Uploaded
docstring_ai-1.0.0.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for docstring-ai 1.0.0
File Interpreter ABI Platform
docstring_ai-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / docstring_ai-1.0.0.tar.gz

Download URL docstring_ai-1.0.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
56c17a76324ccc9fbcd1f8e617e1d7189b12aa90ff558dcf6cbaaebd288f7b09
BLAKE2b-256 checksum
How to use checksums
f1ce77223de9782162a938fd231a78dc510f36d33b56546bb1f7fd2a427669bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.

Transparency log

Release files / docstring_ai-1.0.0-py3-none-any.whl

Download URL docstring_ai-1.0.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6570099cc1faa886d5cff96312edd22959f71d57693f78ac58ef32cef61794a0
BLAKE2b-256 checksum
How to use checksums
6a752aa6786f9a9434d74ce6640696cf45e41d9f1e01419bc2c3d0ee95e006e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page