Add your description here
Project description
cargo-aidoc
cargo-aidoc is a Python script that leverages Large Language Models (LLMs) to automatically generate documentation comments for Rust code items like functions, structs, enums, etc.
Features
- Analyzes Rust source files using
tree-sitter. - Identifies documentable items (functions, structs, enums, etc.).
- Uses LLMs (configurable via
mirascope) to generate documentation comments. - Integrates with Git to prevent overwriting uncommitted changes (can be overridden with
--force). - Configurable via
cargo-aidoc.toml. - Supports dry runs to preview generated documentation.
Installation
This project uses uv for package management.
uv tool install cargo-aidoc
Usage
Run the script pointing it to the root of your Rust crate:
cargo aidoc /path/to/your/rust/crate
Options:
CRATE_PATH: (Required) The path to the Rust crate directory.-q,--quiet: Disable verbose output.--dry-run: Generate documentation but do not write changes to the files.--force: Ignore the Git uncommitted changes check and modify files directly.-c,--clean-cache: Remove the.cargo-aidoccache directory after execution.
Example:
# Generate docs for a crate, showing verbose output, but don't modify files
cargo aidoc . --quiet --dry-run
# Generate and write docs, forcing overwrite even with uncommitted changes
cargo aidoc . --force
Configuration
The script looks for a cargo-aidoc.toml file in the root of the target crate. If it doesn't exist, a default one will be created.
Default cargo-aidoc.toml:
[llm]
# Configuration passed to mirascope.llm.call
# See mirascope documentation for options
provider = "openai"
model = "gpt-4o"
call_params = {} # e.g., {"temperature": 0.5}
[doc]
# Glob pattern relative to the crate root for source files
source = "src/**/*.rs"
# Types of items to document
item_types = ["fn", "struct", "enum", "union", "trait", "macro", "static"]
You can customize the LLM provider, model, call parameters, source file pattern, and the types of Rust items you want to document.
Dependencies
- click: For creating the command-line interface.
- toml: For parsing the configuration file.
- tree-sitter: The core parsing library.
- tree-sitter-rust: Rust grammar for tree-sitter.
- mirascope: For interacting with LLMs.
- termcolor: For colored terminal output.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
The MIT License (MIT) under Computer-Aided Programming Group at Purdue University, see LICENCE
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cargo_aidoc-0.1.1.tar.gz.
File metadata
- Download URL: cargo_aidoc-0.1.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
141dab6c85eb365af58a5a8884199d7cd71e91df3cced78e39328701d09fca7a
|
|
| MD5 |
af7ea57e57f4af9ba74406c15f4a4ba5
|
|
| BLAKE2b-256 |
7a2bf1afc1b5994d5de3bee2d75ee045eb3f9406069ba47b0d5f809f398d1126
|
File details
Details for the file cargo_aidoc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cargo_aidoc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98bcc40e9def6bf0318b9be3862423af18e156472e494d788f6bb38ab2709172
|
|
| MD5 |
68323689c42231bb6a184489fca0b0ae
|
|
| BLAKE2b-256 |
4fce67e1ce1372ce4789bd2d26c5f736a53297a2d9f59a9555449d80d86df446
|