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.2.tar.gz (8.3 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.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cargo_aidoc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8c2ae09bf5a2e5dfc9e2da694c413dfe36a082dbcb377dc44d128ca0a91569c0
MD5 aa40976b89eaf6e232f128609c824329
BLAKE2b-256 78bec6375d9a5a1d1b6667745150d9c3ee1a5a87650b9e4b46aa39c6cd273c06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_aidoc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e5d33a12de7d9e4e82299c473ee37b4ca3a56ef019b66a23dd53738f10ba7856
MD5 33f50164689f6bd932bb61b16c78aa88
BLAKE2b-256 8252b971a99cf56c5c1e5d2ee587cef52404f615028c39fb92833a40fbb407a4

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