AI-powered Code Generation and Refactoring Tool
Project description
AI-powered python code documentation and test generation tool
Write-the is an AI-powered documentation and test generation tool that leverages GPTs to automatically write tests, generate documentation, and refactor code. It is designed to streamline the development process, improve code quality, and increase productivity.
Real-world examples
write-the docs
to write the docs for thewrite-the docs
command 🤖write-the mkdocs
to build the documentation site forwrite-the
🤖write-the tests
to write tests forwrite-the docs
🤖write-the docs
andwrite-the mkdocs
to build documenation forautoresearcher
🤖write-the docs
andwrite-the mkdocs
to build documenation forhyperspec
🤖write-the docs
andwrite-the mkdocs
to build documenation forCUPCAKEAGI
🤖
Installation
pip install write-the
Features
Write-the offers the following AI-driven features:
- Write-the Docs: Automatically generate documentation for your codebase, including class and function descriptions, parameter explanations, and examples.
- Write-the Tests: Create test cases for your code, ensuring thorough test coverage and better code quality.
- Write-the Convert: Convert code and data from any format into another.
Requirements
- Python 3.9 or higher
- OpenAI API key
Usage
To use write-the
you must set an OPENAI_API_KEY environment variable (e.g. export OPENAI_API_KEY=...
).
Docs:
Add google style docstrings to you Python code with AI.
write-the docs [OPTIONS] [PATH_TO_SOURCE_CODE]
By default the write-the docs
command will add docstrings to all the nodes
in the source code that are not already documented.
write-the docs write_the
Save
By default the docstrings will be printed to the console, you can use the --save
flag to write the docstrings to the source code.
write-the docs --save write_the
Generate docs for specific nodes
A node is a function, class or class.method block. You can use the --node
(-n
) flag to specify which nodes to document (this will overwrite existing docstrings).
write-the docs -n function_name -n class_name -n class.method_name write_the
Force and Update
You can also use the --force
flag to overwrite all existing docstrings in the specified folder or file.
write-the docs --force write_the/some_file.py
You can use the --update
flag to update existing docstrings. For example the command that was used to update the docstrings in the write-the
codebase in this commit was:
write-the docs --update --save write_the
Model
View and set the default model that write-the
uses to generate documentation and tests.
write-the model [OPTIONS] [DESIRED_MODEL]
The default model that write-the
uses to generate documentation and tests is gpt-3.5-turbo-instruct
.
You can also use the write-the model <desired_model>
command to set the default model that write-the
uses to generate documentation and tests.
write-the model gpt-4
Use the --list
flag to view all available models.
write-the model --list
MkDocs:
Generate a Markdown based MkDocs website with material theme for a project including an API reference page.
write-the mkdocs [OPTIONS] [PATH_TO_SOURCE_CODE]
The write-the mkdocs
command will generate a mkdocs.yml
file and a docs
folder in the specified directory. In addition a github action workflow file will be generated to automatically build and deploy the documentation to github pages. The --readme
flag can be used to specify the path to the readme file that will be used as the homepage for the documentation site.
write-the mkdocs write_the --readme README.md
The above command will generate the following file structure:
.
├── mkdocs.yml
├── docs
│ ├── index.md
│ └── reference
│ ├── cli.md
│ ├── commands.md
│ ├── cst.md
│ ├── errors.md
│ ├── llm.md
│ ├── models.md
│ └── utils.md
└── .github
└── workflows
└── mkdocs.yml
You can see the documentation site that was generated for the write-the
codebase here.
Tests:
Automatically generate test cases for your codebase using AI.
write-the tests [OPTIONS] [PATH_TO_SOURCE_CODE]
The write-the tests command will generate test cases for all the functions in the specified directory that are not already tested. By default the tests will be printed to the console, you can use the --save
flag to write the tests to the --out
directory (default is tests
).
write-the tests --save write_the
Convert:
Convert code and data from any format into another using AI.
write-the convert [OPTIONS] IN_FILE [OUT_FILE]
By default the write-the convert
command will convert the input file to the output file format using the file extension to determine the input and output format. You can use the --force
flag to overwrite the output file if it already exists.
write-the convert tests/data/multiply.py multiply.rs
$ cat multiply.rs
fn multiply(a: i32, b: i32) -> i32 {
a * b
}
To give the llm model a hint about the input and output format you can use the --input-format
and --output-format
flags.
write-the convert tests/data/multiply.py multiply.rs -o "Verbose Rust with lots of comments"
$ cat multiply.rs
// This is a function named 'multiply' that takes two parameters, 'a' and 'b'.
// Both 'a' and 'b' are of type i32, which is a 32-bit integer.
// The function returns a value of type i32.
fn multiply(a: i32, b: i32) -> i32 {
// The function body consists of a single expression, 'a * b'.
// This expression multiplies 'a' by 'b' and returns the result.
// In Rust, the last expression in a function is automatically returned.
a * b
}
Documentation
For detailed information on available options and parameters, refer to the official (write-the
generated) documentation.
Roadmap
The main goal for write-the is to develop a generic module system to document, test, and optimise code in any language in a reliable and repatable way.
For a detailed project roadmap, including planned features, improvements, and milestones, please see our Project Timeline (TBD).
Contributing
We welcome contributions from the community. If you would like to contribute to Write-The, please follow these steps:
- Fork the repository and create a new branch for your feature or bugfix.
- Develop your changes and ensure that your code follows the project's coding standards.
- Create a pull request with a clear description of your changes and any relevant documentation.
- For more information on contributing, please see our Contributing Guide.
License
write-the
is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
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 write_the-0.12.0.tar.gz
.
File metadata
- Download URL: write_the-0.12.0.tar.gz
- Upload date:
- Size: 4.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a567c27ead80f9a2aba1b9bb29f6976fe49ce8a9b7999af36cbf85df2fd9bfce |
|
MD5 | 73bd5c1be36bde79b0716bb5f6cbc000 |
|
BLAKE2b-256 | 79cf4412b9725fca862c9ccb7d1ad1365e3f793f5d9ed13d2b893227bf74f5e2 |
File details
Details for the file write_the-0.12.0-py3-none-any.whl
.
File metadata
- Download URL: write_the-0.12.0-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cffa318c9e803862f0ec2b9fa8e1b4d8b6baedc55fe2f96c59b5b8b4e071d453 |
|
MD5 | 10d8df45bdb483f9e0966b22fed9bf0c |
|
BLAKE2b-256 | 8e3d981b44c0d3d04b08451f2048cc42946bff4e52b4ec292ab66feda741aff2 |