Skip to main content

DocDocPy

AI-powered, source-preserving documentation for Python code.

DocDocPy is a command-line tool that automatically generates Google-style docstrings for Python code using an LLM, while keeping control of your source code in the hands of the tool—not the model.

Instead of asking an LLM to rewrite your entire Python file, DocDocPy extracts the code elements that need documentation, sends only the relevant information to the model, receives documentation, and inserts the generated docstrings back into the original source.

The result is automated documentation without asking an AI model to reconstruct your code.

Status: Experimental Python: 3.10+ LLM provider: Groq Current model: openai/gpt-oss-120b


Why DocDocPy?

Generating documentation manually can be tedious, especially when working with large Python codebases.

A straightforward approach to AI-generated documentation is to send an entire function or file to an LLM and ask it to return the documented code. This introduces an unnecessary risk: the model may accidentally change code while generating the documentation.

DocDocPy takes a different approach.

Source preservation by design

The LLM is responsible for generating documentation only.

DocDocPy is responsible for modifying the source file.

This separation means the model does not need to reconstruct your functions, classes, imports, or other Python code. The original source is parsed and the generated documentation is inserted programmatically.

Python source
     │
     ▼
 Parse source code
     │
     ▼
 Find documentable objects
     │
     ▼
 Send documentation request to LLM
     │
     ▼
 Receive docstrings
     │
     ▼
 Insert docstrings into original source
     │
     ▼
 Updated Python file

Features

  • Generate Python docstrings automatically using AI

  • Google-style docstrings

  • Source-preserving documentation workflow

  • Supports:

    • Functions
    • Classes
    • Methods
    • Nested/sub-functions
    • Nested/sub-classes
    • __init__ methods
  • Processes multiple documentation targets efficiently

  • Uses Groq as the current LLM provider

  • Uses openai/gpt-oss-120b

  • Secure first-run API-key setup

  • Stores your API key locally on your computer

  • Simple command-line interface

  • No configuration file setup required from the user


Installation

Install DocDocPy directly from PyPI:

pip install docdocpy

Verify the installation:

docdocpy --help

Quick Start

Point DocDocPy at a Python file:

docdocpy my_file.py

On the first run, DocDocPy will ask for your Groq API key.

Your key is stored locally on your computer so you don't need to enter it every time you use DocDocPy.

After setup, simply run:

docdocpy my_file.py

DocDocPy will analyze the Python file, generate documentation for supported objects, and insert the resulting docstrings directly into the file.


Example

Before

def calculate_total(price, quantity, discount=0):
    subtotal = price * quantity
    return subtotal - discount

Run:

docdocpy shop.py

After

def calculate_total(price, quantity, discount=0):
    """Calculate the final price after applying a discount.

    Args:
        price: The price of a single item.
        quantity: The number of items.
        discount: The discount amount to subtract from the subtotal.

    Returns:
        The final calculated price after the discount.
    """
    subtotal = price * quantity
    return subtotal - discount

The important distinction is that the LLM generates the docstring, while DocDocPy inserts it into the original function.


Supported Python Code

DocDocPy currently supports documentation of:

Functions

def calculate_area(width, height):
    ...

Classes

class UserManager:
    ...

Methods

class UserManager:
    def create_user(self, name):
        ...

Nested functions

def process_data(data):

    def clean_data(value):
        ...

Nested classes

class Application:

    class Configuration:
        ...

__init__

class User:

    def __init__(self, name, age):
        ...

DocDocPy is designed to discover these objects from the Python source rather than relying on simple text matching.


How It Works

DocDocPy deliberately separates code analysis, documentation generation, and source modification.

1. Parse

The Python source is parsed to identify supported functions, classes, and methods.

2. Extract

Relevant information about each object is extracted for documentation generation.

3. Generate

The extracted information is sent to the Groq API.

The current model is:

openai/gpt-oss-120b

The model is instructed to generate documentation only, rather than returning reconstructed Python code.

4. Validate

The response is checked so that generated documentation can be associated with the correct Python object.

5. Insert

DocDocPy inserts the generated docstrings into the original source programmatically.

This is the core of the source-preserving approach.


API Key

DocDocPy currently supports Groq API keys only.

On the first invocation that requires the API:

docdocpy my_file.py

DocDocPy prompts you for your API key.

The key is stored locally using the operating system's appropriate application configuration directory through platformdirs.

You therefore do not need to:

  • Put your API key inside your Python files
  • Add it to the DocDocPy package
  • Enter it every time you run the tool

Support for additional LLM providers is planned for future versions.


Current Limitations

DocDocPy is currently experimental, so its interface and behavior may change as development continues.

The current version intentionally keeps the interface simple.

At the moment:

  • Groq is the only supported LLM provider.
  • Google is the only supported documentation style.
  • The input Python file is modified directly.
  • There is currently no output-file option.
  • There is currently no command-line option for selecting a documentation style.
  • Additional documentation targets and capabilities are planned for future releases.

Always review generated documentation before committing significant changes to a codebase.


Roadmap

DocDocPy is still evolving. Planned functionality includes:

  • Support for additional LLM providers

  • Additional documentation styles

    • NumPy
    • Sphinx
    • Other commonly used Python documentation formats
  • Output-file support

  • Documentation-only / selective targets

  • Additional Python constructs

  • More configuration options

  • Improved control over documentation generation

  • Additional CLI options

The roadmap may change as the project develops and user feedback is incorporated.


Development

Clone the repository and install the project locally:

git clone <repository-url>
cd docdocpy
pip install -e .

Install development dependencies if provided by the project:

pip install -e ".[dev]"

Run the CLI:

docdocpy my_file.py

Project Philosophy

DocDocPy is built around a simple principle:

Let AI write the documentation. Don't let AI rewrite your code.

Large language models are useful for understanding code and producing natural-language explanations. They do not need to be responsible for reconstructing the source code just to add a docstring.

By separating these responsibilities, DocDocPy aims to make AI-assisted documentation more predictable and safer to use.


Contributing

DocDocPy is experimental and open to contributions.

If you find a bug, have an idea, or want to improve the documentation or implementation, feel free to open an issue or submit a pull request.

When contributing, please keep the project's core principle in mind:

The generated documentation should not require the LLM to rewrite the user's source code.


License

This project is licensed under the MIT License.


Author

Emmanuel Ebi-Fredrick

If you find DocDocPy useful, consider giving the project a ⭐ on GitHub.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docdocpy-0.1.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docdocpy-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file docdocpy-0.1.0.tar.gz.

File metadata

  • Download URL: docdocpy-0.1.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for docdocpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d87013c4cfdc99b252e4bc9a221cff870fe86b1f980b9309ad5daee9d6d3bb6
MD5 98d8c81bfcdff7e18b91109a4505ee28
BLAKE2b-256 70891f8689e4c191e09d7601e66a130ee7c139762fa3d7caf5464d2275e62fdd

See more details on using hashes here.

File details

Details for the file docdocpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: docdocpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for docdocpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4bbe860e6d975a69691b2312532f72a402575ff3f0c735448787fcba06d8001d
MD5 f78a7710fe502f72ce769c214a88047e
BLAKE2b-256 58539f6bbd96373bdb8f2611366f06afa680b07509fc36840dfeb9e09c137a4b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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