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.0.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.0-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rigby_toon-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 80561426a7e44a63ca006167b8a5813d17ef425e4bd3942c29aaed966bbae708
MD5 4ef5a7237302f1642cfb126bb858602e
BLAKE2b-256 29fbc3effe1ea0ceb2f6b913ca7c20a47075aa198aa0750b7fde23e581bff440

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rigby_toon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2168dfce9e570f66f082c01cec4ce25eae8775ddfbb1e1db32e3fcca2c66c24d
MD5 aaf4632af4aebda3bf9e785a8bdeadbb
BLAKE2b-256 4646bb44fb53d5f4174c7732d0f6838d8f46a78ff30160929b7c34cbb8d439d1

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