Skip to main content

A Python library for generating Google-style docstrings.

Project description

Project Documentation

Welcome to the project documentation. This README file provides an overview of the project, including setup instructions, usage guidelines, and other relevant information.

Table of Contents

Introduction

PyCodeCommenter is a Python library designed to automatically generate Google-style docstrings for Python functions and classes. It analyzes your code and provides structured documentation that enhances code readability and maintainability. The library supports both direct code input as strings and file input, making it flexible for different use cases.

Installation

  1. Clone the repository:
 git clone https://github.com/yourusername/yourproject.git
  1. Install dependencies:
 pip install ast
 pip install requests

clone the repository and install the required dependencies. You can install the library directly from your local file system in editable mode.

# Example installation command
git clone https://github.com/yourusername/yourproject.git
cd yourproject
npm install

Usage

To use the PyCodeCommenter library, follow these steps to generate docstrings for your Python code. You can provide code through either direct string input or by reading from a Python file.

String Input Method You can use the from_string method to directly input code as a string. Here’s an example:

from commenter import PyCodeCommenter

# Example functions for code_string input
code_string = """
def add(a: int, b: int) -> int:
    return a + b

def greet(name: str) -> None:
    print(f"Hello, {name}!")
"""

# Create an instance and use the string input method
commenter = PyCodeCommenter().from_string(code_string)

# Generate docstrings and print them
docstrings = commenter.generate_docstrings()
for docstring in docstrings:
    print(docstring)

File Input Method To read code from a file, use the from_file method. Here’s an example:

from commenter import PyCodeCommenter

# Specify the path to your Python file
code_file = "path/to/your/code.py"

# Create an instance and use the file input method
commenter = PyCodeCommenter().from_file(code_file)

# Generate docstrings and print them
docstrings = commenter.generate_docstrings()
for docstring in docstrings:
    print(docstring)

You can choose between the two methods depending on your needs. The library is designed to be user-friendly and efficient, allowing you to seamlessly integrate documentation generation into your development workflow.

Features Automatic Docstring Generation: Automatically creates Google-style docstrings for functions and classes in your code, improving documentation quality and consistency.

Support for Both Input Methods: Allows users to input code as a string or read from a Python file, providing flexibility based on user preference.

Type Annotations Handling: Analyzes and incorporates Python type annotations into the generated docstrings, ensuring that the documentation accurately reflects the function signatures.

Error Handling: Provides meaningful error messages for unsupported code structures or syntax errors, making it easier to troubleshoot issues.

Editable Installation: Supports editable installation, allowing developers to make changes to the library and see the effects without reinstalling.

Robust Testing: Includes unit tests to ensure reliability and accuracy of the documentation generation process.

Contributing

Explain how others can contribute to the project. Include guidelines for submitting issues and pull requests.

License

This project is licensed under the MIT License.

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

pycodecommenter-0.0.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

PyCodeCommenter-0.0.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file pycodecommenter-0.0.2.tar.gz.

File metadata

  • Download URL: pycodecommenter-0.0.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for pycodecommenter-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2ddc66d6000b0476016527d8d0d73c3e5e6d7239c5042cbac772598dd35d139f
MD5 c4c0ca9e31774620c03819be288dcb8a
BLAKE2b-256 effcac68bac8d7eadfd0532b897bc213e7cc0fef3bb3db344e7eac8feaf52c4d

See more details on using hashes here.

File details

Details for the file PyCodeCommenter-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for PyCodeCommenter-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d06c5cabfe3b2ba7c6c3b11dff5fb0c3661fbe76040c32d76c3554c68e45dde9
MD5 3d684eba122488e5f991acdf5c967e04
BLAKE2b-256 4d7cac1227b7c91d6be9b508f1cc6ac7c74e65a073bbbdb4d519db46acda9d9a

See more details on using hashes here.

Supported by

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