Skip to main content

A python AST parser that extracts code skeletons into TOON format.

Project description

🦴 Rigby - The Code Raccoon 🦝

Rigby parses Python code and extracts its skeletal structure into TOON format. It's useful for feeding code context to LLMs without using too many tokens, or for quickly understanding the high-level architecture of a project.

Features

  • AST Parsing: Uses Python's native ast module (safe, no execution).
  • TOON Format: A concise representation of:
    • Classes (CLS) & Inheritance
    • Functions (FUNC) & Async Functions (ASYNC_FUNC)
    • Methods (MTHD) & Async Methods (ASYNC_MTHD)
    • Global Variables (VAR)
    • Docstrings (flattened & truncated)
  • Robust: Handles complex type hints, decorators, and directory recursion.

Installation

You can install Rigby using pip or uv.

Using uv (Recommended)

uv pip install rigby-toon

Using pip

pip install rigby-toon

Usage

Command Line

Run Rigby against a file or a directory:

# Parse a single file
rigby parse my_script.py

# Parse an entire directory recursively
rigby parse ./my_project/

Output Example (TOON Format):

CLS Dog(Animal):
  MTHD __init__(self, name:str): "Initializes a dog."
  MTHD bark(self) -> None: "Makes noise."

FUNC main():

Python API

You can also use Rigby in your own scripts:

from rigby import parse_file, process_path

# Get TOON string for a single file
toon_context, item_count = parse_file("path/to/file.py")
print(toon_context)

# Process directory (prints to stdout)
process_path("path/to/project")

Development

This project is managed with uv.

  1. Clone the repo:

    git clone https://github.com/yourusername/rigby.git
    cd rigby
    
  2. Install dependencies:

    uv sync
    
  3. Run Tests:

    uv run pytest
    
  4. Lint & Format:

    uv run ruff check .
    uv run ruff format .
    

Publishing

To publish to PyPI (requires uv):

uv build
uv publish

License

MIT

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

rigby_toon-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

rigby_toon-0.1.1-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

Details for the file rigby_toon-0.1.1.tar.gz.

File metadata

  • Download URL: rigby_toon-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.0

File hashes

Hashes for rigby_toon-0.1.1.tar.gz
Algorithm Hash digest
SHA256 54af96e5fd04827ad7a9042f986d006d3c8740ced70f9b044afeb342ac68b85e
MD5 f2905f6de488fcc531651723daaee17b
BLAKE2b-256 51951f27ca0d36dfe07e93c910c441f81d599529c82dd81127961d5cf33e6b99

See more details on using hashes here.

File details

Details for the file rigby_toon-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rigby_toon-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9b22d351037dd09a76c81c0507a5b7417b97aa31434d68d9ecbbd1f123dd45d
MD5 009164f576dbb3dc64870cb1bd3e9fa9
BLAKE2b-256 7c1f5cb099c1e78227faceaf8067d48711bc098fe7cc714d8055cdbb9fa02493

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