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.
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.
-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.