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.4.0.tar.gz (14.1 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.4.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codetre-0.4.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for codetre-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c1b6915a26a479d2378a0cd612169cfbd8d6268fb1d67bfac0a14c1beceb67e2
MD5 b1dc3eb38621eec85fb1fa51ce965d0a
BLAKE2b-256 66a88341d59357fdbc003d6cc08eb90bfd1a5126dad069a04df00a66a29a21e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codetre-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for codetre-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d20ecdab2fdd7a9424a0ae488756cc656af43ee540139a0f7e267e7583a2678
MD5 55b6e707b5e561a99a24820c53525e4a
BLAKE2b-256 a8286290045aa8c9928437bfdbab56fb8ea6b6434f4601b06ef31cf667decec6

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