Skip to main content

AutoDoc

CLI tool that generates documentation comments for source code using Tree-sitter parsing and a local Ollama model. Initially supports C (.c, .h).

Requirements

  • Python 3.12+
  • uv for environment management
  • Ollama running locally with a compatible code model (e.g., qwen2.5-coder:7b)

Install

Development Installation

# Clone the repository
git clone https://github.com/pierrelgol/autodoc-cli.git
cd autodoc-cli

# Create virtual environment and install in development mode
uv venv --python 3.12.11
uv pip install -e .[dev]

Production Installation

# Install from PyPI (when published)
uv pip install autodoc

# Or install from local wheel
uv pip install dist/autodoc-0.1.0-py3-none-any.whl

Usage

# Basic usage
autodoc /path/to/target --model qwen2.5-coder:7b

# Dry run to see what would be changed
autodoc /path/to/target --dry-run

# Use a different model
autodoc /path/to/target --model llama3.1:8b

# Specify a custom database location
autodoc /path/to/target --db /path/to/custom.db

# Example: Generate documentation for a C project
autodoc /path/to/c-project --model qwen2.5-coder:7b

By default, a SQLite DB .autodoc.sqlite will be created in the target directory to track function body hashes for change detection.

How it works

  • Tree-sitter is used to parse C files into ASTs. No regex is used for detection.
  • For each function:
    • If a doc comment exists and the function hash matches the DB, the function is skipped.
    • If a doc exists but the hash changed, the doc is regenerated and replaced.
    • If no doc exists, a new doc comment is generated and inserted above the function.
  • Edits are applied directly to the source files and are idempotent.

Example

Before running autodoc:

int calculate_fibonacci(int n) {
    if (n <= 1) {
        return n;
    }
    return calculate_fibonacci(n - 1) + calculate_fibonacci(n - 2);
}

After running autodoc . --model qwen2.5-coder:7b:

/**
 * Calculates the nth Fibonacci number using recursion.
 *
 * @param n The position in the Fibonacci sequence (0-based).
 * @return The Fibonacci number at position n.
 */
int calculate_fibonacci(int n) {
    if (n <= 1) {
        return n;
    }
    return calculate_fibonacci(n - 1) + calculate_fibonacci(n - 2);
}

Notes

  • Only C is supported currently. Additional languages can be added by implementing the LanguageAdapter interface in autodoc/adapters.
  • Ensure Ollama is running locally: ollama serve and that the model is available: ollama pull qwen2.5-coder:7b.
  • If you prefer uvx, be aware that uvx autodoc may resolve to the PyPI package named autodoc. Use the local script instead: .venv/bin/autodoc.

Metadata

Release files for autodoc-cli 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autodoc-cli 0.2.1
File Size Uploaded Provenance
autodoc_cli-0.2.1.tar.gz 51.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for autodoc-cli 0.2.1
File Interpreter ABI Platform
autodoc_cli-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 70.7 kB

Release files / autodoc_cli-0.2.1.tar.gz

Download URL autodoc_cli-0.2.1.tar.gz
Size 51.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9401f8e18c13156dc5a2010c1e7377f354764cd19da8e72dd56277ef7f9aa1e1
BLAKE2b-256 checksum
How to use checksums
5bc602528edf114950d6fca310512dca8066698a124070763dbe3ad55044632b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / autodoc_cli-0.2.1-py3-none-any.whl

Download URL autodoc_cli-0.2.1-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f987227c01b9e0e40f22e0e8d8b22c16b171d65c7213aa52e0216a6b25991876
BLAKE2b-256 checksum
How to use checksums
b1e9d0785ff051f9bd4220d76ea84a3a633c9ae1351e120cb4869c315cba63ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Security for autodoc-cli 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page