Skip to main content

AST-based code structure outline tool — generate hierarchical symbol maps with call relationships

Project description

codetre

AST-based code structure tree tool.

Extracts classes, functions, methods and their call relationships into a clean hierarchical view. Uses ast-grep for AST-level accuracy across multiple languages.

Requirements

  • Python ≥ 3.10
  • ast-grep (sg) installed and on PATH

Installation

pip install codetre

Usage

# Scan current directory
codetre

# Scan specific directory
codetre src/

# Scan single file
codetre src/main.py

# Scan multiple files / directories
codetre src/main.py tests/

# JSON output
codetre --json src/

# Exclude patterns
codetre --exclude "test_*" --exclude "*_gen.py" src/

Supported Languages

Python, JavaScript, TypeScript, Go, C, C++, Java, Rust, Ruby, Kotlin, Scala, C#, PHP, Swift, Lua, Bash, and more.

Output Example

# format: name:start,count  -> [file-local ref, ...]

file: src/services/auth.py,84
  import hashlib
  import jwt

  class AuthService:9,76
    func __init__:14,7 -> [_load_secrets]
    func login:22,20  -> [_generate_token, _verify_password]
    func validate_token:43,20
    func _load_secrets:64,12
    func _generate_token:77,4
    func _verify_password:82,3
  func logout:32,8
  var SECRET_KEY:6

file: src/main.py,39
  import os
  from .services import AuthService

  class App:8,32
    func register_user:15,8
    func place_order:24,15 -> [validate_token, create_order]
  func create_app:4,3
  var VERSION:1

Each symbol shows kind name:start_line,line_count. Container symbols (class/struct/interface) have their children indented underneath. Call relationships appear as -> [callee, ...].

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

codetre-0.3.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

codetre-0.3.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file codetre-0.3.0.tar.gz.

File metadata

  • Download URL: codetre-0.3.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for codetre-0.3.0.tar.gz
Algorithm Hash digest
SHA256 caadb0eff86365bbb0d4eddca084c6fe3c412a0020f40612b511942eaaed01ab
MD5 baaf5c344e328f32c6c56bb3b58597e4
BLAKE2b-256 818baad2de87a532e4dfa2c0cb937b6640ec09e2829f7842368782c1daf100bd

See more details on using hashes here.

File details

Details for the file codetre-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: codetre-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for codetre-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6ef59245fb5ea47db39f8ee5986b9618aa6cddf81985ea706aaeed76985f0be
MD5 0669f79589718f7843ac4e82cb6e9b13
BLAKE2b-256 774661f0d63a0d7f9c8c758ff7b7da01231395a50b7cf664141a380c6645c15b

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