Anthropic Auto Docstrings Generator
Project description
Source Code: https://github.com/JordanM575/anthropicautodocstrings
Anthropicautodocstrings is a command-line tool with the following key features:- Updates the docstrings in Python files using the Anthropic API.
- Can process a single file or a directory of files, including all subdirectories.
Anthropicautodocstrings uses the Anthropic API to generate docstrings, so these are not guaranteed to be perfect. The claude-3-haiku-20240307 model is used to generate the docstrings. This is the fastest. The version this was forked from is slow in comparison. To increase raw speed! This runs asyncronously.
Anthropicautodocstrings will work best for code that already has good type hints. Without type hints, the Anthropic API will have to guess input and return types, which may not be accurate.
Requirements
- Python 3.10+
- A valid Anthropic API KEY. Set in the environment variables.
Installation
To install the dependencies for this tool, run the following command:
$ pip install anthropicautodocstrings
Usage
To use this tool, run the following commands:
$ export ANTHROPIC_API_KEY=1234567890
$ aads INPUT `
[--replace-existing-docstrings] `
[--skip-constructor-docstrings] `
[--exclude-directories EXCLUDE_DIRECTORIES] `
[--exclude-files EXCLUDE_FILES]
Where INPUT is a Python file or directory containing Python files to update the docstrings in, API_KEY is your Anthropic API key, and the optional flags --replace-existing-docstrings and --skip-constructor-docstrings can be used to skip updating docstrings for constructors (init methods) and replacing existing docstirngs. EXCLUDE_DIRECTORIES and EXCLUDE_FILES are comma-separated lists of directories and files to exclude from the update.
Examples
Update the docstrings in all Python files in the my_code directory:
$ aads cool_code/
Update the docstrings in the my_file.py file:
$ aads awesome_script.py
Update the docstrings in all Python files in the my_code directory and replace existing ones:
$ aads cool_code/ --replace-existing-docstrings
Update the docstrings in all Python files in the my_code directory, but skip updating docstrings for class constructors (init methods):
$ aads cool_code/ --skip-constructor-docstrings
Update the docstrings in all Python files in the my_code directory, but exlcude the exclude_dir directory and the exclude_file_1.py and exclude_file_2.py files:
$ aads my_code/ --exclude-directories exclude_dir --exclude-files exclude_file_1.py,exclude_file_2.py
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
Built Distribution
File details
Details for the file anthropicautodocstrings-0.0.6.tar.gz
.
File metadata
- Download URL: anthropicautodocstrings-0.0.6.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 913ba87e1760aba9cee7761a30b1a01a59bc7b4500fe6c99ebfbf1db598b1ff1 |
|
MD5 | 80676242307ab382238a54c4c960e133 |
|
BLAKE2b-256 | dffe3b21f926136107d9a31db29e8c02883bc85a8afc76b4b175c9b46bec891a |
File details
Details for the file anthropicautodocstrings-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: anthropicautodocstrings-0.0.6-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cd57a93d6eef3933a96f251e3e58a3c3db6519adeac2e5ae7b061f69dc83afa |
|
MD5 | 0787a99c52a93c388abb8456aea035c9 |
|
BLAKE2b-256 | 605814e0f6bd16f6e6f02bc8046dce00d0b9e4c9a4ba0995cba1ba61759d1d92 |