Skip to main content

gpt4docstrings

Project description

gpt4docstrings logo

gpt4docstrings

Generating Python docstrings with OpenAI ChatGPT!!


PyPI Status Python Version License

Read the documentation at https://gpt4docstrings.readthedocs.io/ Tests Codecov

pre-commit Black

What is gpt4docstrings?

gpt4docstrings is a library that helps you to write docstrings for your Python code. Select a path / paths where you want gpt4docstrings to be applied and wait for the results!!

Requirements

gpt4docstrings supports Python 3.9 and above.

Installation

You can install gpt4docstrings via pip from PyPI:

$ pip install gpt4docstrings

Usage

Command Line Interface

The first option when using gpt4docstrings is to use it as a Command Line Interface (CLI).

The following is an example command that generates docstrings for all the non-documented classes / functions under src/ directory.

gpt4docstrings src/

Another quite common situation is that we want to exclude the tests/ folder, for example, from the generation of docstrings. Doing this is very simple.

gpt4docstrings --exclude tests/ .

Lastly, you could also run gpt4docstrings in a specific Python file.

gpt4docstrings ./src/example.py

Remember that, if you don't have your OpenAI API Key defined as an Environment Variable (OPENAI_API_KEY), gpt4docstrings can accept the API Key as an option.

gpt4docstrings --exclude tests/ --api_key sk-xxxxxxxxxxxx .
pre-commit hook

Another cool use of gpt4docstrings is as a precommit hook. All you have to do is add it to your configuration file and you’re done!

repos:
  - repo: https://github.com/MichaelisTrofficus/gpt4docstrings
    rev: v0.1.0
    hooks:
      - id: gpt4docstrings
        name: gpt4docstrings
        language: python
        entry: gpt4docstrings
        types: [python]

Please see the Command-line Reference for more details!!

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, gpt4docstrings is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.

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

gpt4docstrings-0.1.1.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distribution

gpt4docstrings-0.1.1-py3-none-any.whl (15.0 kB view hashes)

Uploaded Python 3

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