docstring_generator

Python 3.10 PyPI version Actions Ruff uv VS Code Extension

Stop writing boilerplate docstrings by hand. docstring_generator reads your type hints and generates professional, standards-compliant documentation in seconds — keeping your codebase clean, consistent, and AI-ready.

Python documentation tooling that automatically generates docstrings for functions and class methods from their type hints, with full support for NumPy, Google, and reStructuredText styles.


Why docstring_generator?

Good documentation is no longer optional. AI coding assistants, static analysis tools, and auto-generated API docs all depend on structured, accurate docstrings. Yet writing them by hand is tedious, error-prone, and rarely kept up-to-date.

docstring_generator solves this by:

  • ⚡ Saving hours — generate docs for an entire codebase in one command
  • 🔄 Staying in sync — re-running only updates what changed in the function signature
  • ✍️ Preserving your words — existing descriptions and custom notes are never overwritten
  • 🧠 AI-workflow friendly — well-structured docstrings improve context quality for LLM-assisted development
  • 🚨 Exception-aware — automatically detects raise statements and documents them in a Raises section
  • 🙈 Convention-correct — self and cls are automatically excluded from generated parameter sections
  • ⚙️ Async-ready — handles both def and async def functions transparently
  • 🎨 Style-safe — detects the existing docstring style and refuses to silently mix conventions
  • 🏎️ Blazing fast — core engine written in C++ via pybind11

Quick Start

pip install docstring-generator
gendocs_new file.py        # single file
gendocs_new mydir/         # entire directory

That's it. Your functions now have properly formatted docstrings.

💡 Prefer working inside your editor? Install the VS Code extension or use the JetBrains File Watcher to generate docstrings automatically on every save.


How It Works

The core engine is implemented in C++ (C++20) and exposed to Python via pybind11, delivering performance that scales to large codebases without slowing down your workflow.


License

Apache-2.0 — free to use in personal and commercial projects.


Buy Me A Coffee