VOOZH about

URL: https://www.scriptbyai.com/generate-python-docstrings-chatgpt/

โ‡ฑ Generate Python docstrings With ChatGPT - gpt4docstrings


Skip to content

gpt4docstrings is a Python library that leverages OpenAIโ€™s GPT AI models to generate docstrings for your Python code.

It scans your codebase and suggests high-quality docstrings based on the function and variable names, parameters, and logic. This saves time and enforces docstring conventions.

GitHub Repo

How to use it:

1. Install the gpt4docstrings library.

$ pip install gpt4docstrings

2. After installation, it can be used in two different ways โ€“ as a Command Line Interface (CLI) tool or as a pre-commit hook in your project.

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

3. Available options.

  • -h: Show help text.
  • -v: Verbosity parameter
  • -e: Exclude PATHs. Multiple -e invocations are supported.
  • -k: OpenAI API key. If not provided, the library will try to access OPENAI_API_KEY environment variable.
  • -s: โ€˜googleโ€™, โ€˜reStructuredTextโ€™, โ€˜epytextโ€™, โ€˜numpyโ€™
  • -m: Specify the model. Defaults to gpt-3.5-turbo.

Leave a ReplyCancel Reply

Trending now

Get the latest & top AI tools sent directly to your email.

Subscribe now to explore the latest & top AI tools and resources, all in one convenient newsletter. No spam, we promise!