A simple tool for analyzing your codebase architecture
Project description
treeline
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.
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
- Fork the repository
- Create your feature branch (git checkout -b branch)
- Commit your changes (git commit -m 'cool stuff')
- Push to the branch (git push origin branch)
- Open a Pull Request
Sources for best practices
- https://peps.python.org/
- https://peps.python.org/pep-0008/
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treeline-0.1.2.tar.gz.
File metadata
- Download URL: treeline-0.1.2.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5b6091c9d9cebdfbf47c5771ed3505e11e8ac6a7756c1b0e3e09d3dda59e1ed
|
|
| MD5 |
02932e552b254a3642c3279cdd0ec455
|
|
| BLAKE2b-256 |
f021e3339f18f096fdcfa465706bb1e5d200a998cfc6208c3f1624d592be34ea
|
File details
Details for the file treeline-0.1.2-py3-none-any.whl.
File metadata
- Download URL: treeline-0.1.2-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76ab5adfebfab50408f7e374e608e4cb4bb4bae60d4ec919e73dc0cb1105a650
|
|
| MD5 |
3fc67cab498707c347ebd5c3acc9b28b
|
|
| BLAKE2b-256 |
dd4a8155895f0b86acb6ce0fff34b702d9c2765de82fa02ba043b76f6100b72f
|