Skip to main content

A tool to analyze Python functions' docstrings and provide critiques and suggestions for improvement

Project description

Docstring Auditor

tests

Introducing Docstring Auditor, a cutting-edge solution to ensure that your Python code documentation remains accurate and up-to-date. Tired of encountering misleading or outdated docstrings that no longer align with your code's functionality? You're not alone! That's why we've developed Docstring Auditor, a powerful tool that leverages the prowess of large language models to analyze and critique your docstrings, ensuring they accurately reflect your code's true purpose. Say goodbye to technical discrepancies and confusing descriptions. With Docstring Auditor, you can effortlessly bridge the gap between your code and its documentation, making it more accessible and understandable to both experts and novices alike. Step into the future of code documentation with Docstring Auditor – the ultimate companion for maintaining crystal-clear, precise, and informative docstrings.

Features

  • Analyzes Python functions' docstrings in a given file
  • Identifies errors, warnings, and possible improvements
  • Provides detailed critiques and suggestions for better docstrings
  • Powered by OpenAI's GPT for accurate and insightful analysis
  • Easy to use command-line interface

Installation

To install Docstring Auditor, first, ensure you have Python 3.6 or higher installed. Then, install with:

pip install docstring-auditor

Usage

Using Docstring Auditor is as easy as running the following command:

docstring-auditor path/to/your/python_file.py

The tool will then analyze the functions' docstrings in the specified file and display the critiques and suggestions for improvement.

Example Let's say you have a Python file called example.py with the following content:

def compute(a, b):
    """
    Add two numbers.

    Parameters
    ----------
    a : int or float
        The first number to be added or from which 'b' will be subtracted.
    b : int or float
        The second number to be added or subtracted.

    Returns
    -------
    int or float
        The result of the addition operation.
    """
     if a > 0:
        return a + b
     else:
        return a - b

To analyze the docstring of the add function, run:

docstring-auditor example.py

Docstring Auditor will then provide you with a detailed analysis of the docstring, including any errors, warnings, and suggestions for improvement. The output may look like...

Processing function 1 of 1...
--------------------------------------------------------------------------------
An error was found in the function: compute

The docstring states that the function adds two numbers, but the code also performs subtraction if 'a' is less than or equal to 0. The docstring should accurately describe both addition and subtraction operations.

A warning was found in the function: compute

The docstring does not follow the numpydoc style completely. The summary line should be a one-line summary, and the extended description should be provided in a separate paragraph.

A proposed solution to these concerns is:

"""
Add or subtract two numbers based on the value of 'a'.

This function performs addition if 'a' is greater than 0, and subtraction if 'a' is less than or equal to 0.

Parameters
----------
a : int or float
    The first number to be added or from which 'b' will be subtracted.
b : int or float
    The second number to be added or subtracted.

Returns
-------
int or float
    The result of the addition or subtraction operation.
"""

Contributing

We welcome contributions to Docstring Auditor! If you'd like to contribute, please fork the repository and submit a pull request with your changes. We also appreciate bug reports and feature requests submitted through the GitHub issues page.

Project details


Download files

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

Source Distribution

docstring_auditor-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

docstring_auditor-0.1.0-py2.py3-none-any.whl (9.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: docstring_auditor-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for docstring_auditor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 396b4437604d4c01eabaeee2e51b3c6c3f2465deee1cb2c4e64e2c1aad5ccdca
MD5 eb43f97d17ee73647ac82e4ff1f20002
BLAKE2b-256 d57d9289bc1782a00a2a6eb81cb46e4e7dbd78690f0b85f53c7f843c0a9e56e0

See more details on using hashes here.

File details

Details for the file docstring_auditor-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for docstring_auditor-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e457a40f21211dff66bc34fe97606ecc991a0345c71417622a6a619b741c98c1
MD5 4fbb33d58d5637b861660dc2f64c9223
BLAKE2b-256 4fdee354402ce8464a1842fb26bed1c68effc13a5efe478f1ed4421d81e74380

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page