Skip to main content

A simple tool for analyzing your codebase architecture

Project description

treeline

Treeline Logo

A Python toolkit for analyzing and visualizing code structure, dependencies, and generating directory trees. treeline helps developers understand codebases through ASCII tree representations, interactive dependency graphs, and structural diff visualizations.

Screenshot

Installation

pip install treeline

Usage

As a python module

from treeline import treeline

# Generate and print tree structure
print(treeline("/path/to/directory"))

# Generate tree and save to markdown file
treeline("/path/to/directory", create_md=True)

# Advanced code analysis
from treeline.dependency_analyzer import ModuleDependencyAnalyzer
from treeline.diff_visualizer import DiffVisualizer
from pathlib import Path

# Analyze code dependencies
analyzer = ModuleDependencyAnalyzer()
analyzer.analyze_directory(Path("."))

# Generate interactive visualization
with open("dependencies.html", "w", encoding="utf-8") as f:
    f.write(analyzer.generate_html_visualization())

# Compare code structure between git commits
visualizer = DiffVisualizer()
diff_html = visualizer.generate_structural_diff("HEAD^", "HEAD")
with open("code_diff.html", "w", encoding="utf-8") as f:
    f.write(diff_html)

In terminal

Basic commands

# Show current directory tree
treeline
# Show specific directory tree
treeline /path/to/dir
# Create markdown file + report in html format (tree.md)
treeline -m
# Ignore specific patterns
treeline -i ".pyc,.git"
# Show help message
treeline -h

Visualization Options

# Hide all code structure details
treeline --hide-structure
# Hide function parameters
treeline --no-params

Configuration

.treeline-ignore

the .treeline-ignore will ignore whatever is in the folder.

Place .treeline-ignore in any directory to apply rules to that directory and its subdirectories.

# Ignore all .pyc files
*.pyc

# Ignore specific directories
__pycache__
.git
.venv

# Ignore specific files
config.local.py
secrets.py

Analysis configuration

Create a treeline.config.json to customize analysis settings:

{
  "complexity_threshold": 10,
  "ignore_patterns": [".pyc", ".git"],
  "relationship_types": ["imports", "calls", "contains"],
  "visualization": {
    "layout": "force-directed",
    "theme": "light"
  }
}

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b branch)
  3. Commit your changes (git commit -m 'cool stuff')
  4. Push to the branch (git push origin branch)
  5. Open a Pull Request

Sources for best practices

  1. https://peps.python.org/
  2. https://peps.python.org/pep-0008/
  3. https://google.github.io/styleguide/pyguide.html

Author

Oha

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

treeline-0.1.1.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

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

treeline-0.1.1-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: treeline-0.1.1.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for treeline-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff5df99f257de56cbfd50a6e856bb1f5968e44f13b5d8ec4455967e4e73acf1d
MD5 ce5784f6d2871d975a120b5c6b4dba31
BLAKE2b-256 bf692afdc96b614f5b9a06278aeaee956fb6d03ed62b1cdb1ddbcd1caa4bed6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: treeline-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for treeline-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 506d85eae26277d383cd85eff2f9030f9538497b5f9c6ab011f1733fb6b1ccfd
MD5 e81648c0fe6d23533216e2af788d99df
BLAKE2b-256 9b044659f66ef1029ed1a9ae9f9d26befd7b8da53b716f3df3370de545d7a153

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