Skip to main content

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-aidoc cache 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

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

cargo_aidoc-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cargo_aidoc-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file cargo_aidoc-0.1.0.tar.gz.

File metadata

  • Download URL: cargo_aidoc-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for cargo_aidoc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 311c20f6e68ca76626b94d763e54548caa2aaaad121a177937310dc5a60c579d
MD5 27c40dea7a9405cd6fe0448bb3e545a4
BLAKE2b-256 f03e430bd559138120324ca51599167cb96adace0a9d80ed1fbaa6399f342974

See more details on using hashes here.

File details

Details for the file cargo_aidoc-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cargo_aidoc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 347052a8719908b0a0a602a43b6144da9a06d43e665fa8c78300a53751c5bcef
MD5 7dca1944ee1158879eb6999bfb30cef0
BLAKE2b-256 da5d4ecbc46fc6f5bed4237343f6bb4e9fea80c39c090d44bc21204ead3dcaf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page