Skip to main content

Generate annotated file tree structures with descriptions from file comments

Project description

Welcom to Annotree 🌳

PyPI version Python Support

Annotree generates annotated file trees that read like your code is documenting itself — while preserving Python-style annotations. It automatically extracts descriptions from file comments, docstrings, and __init__.py headers, keeping your project’s natural Python annotation style intact. Perfect for README files, documentation, and quick project overviews.


⚡ Key Features

  • 🧠 Automatic Annotations – Pulls descriptions from first lines, comments, or __init__.py docstrings
  • 📁 Directory Descriptions – Folders inherit descriptions from __init__.py
  • 🚫 Smart Ignore Support – Honors .treeignore or .gitignore automatically
  • 🎨 Clean, Aligned Output – Beautiful tree structure with readable annotations
  • ⚙️ Customizable – Control depth, output format, and annotation alignment
  • 🐍 Python API & CLI – Use as a library or from the command line

💻 Installation

Using uv (recommended)

uv pip install annotree

Using pip

pip install annotree

For Development

git clone https://github.com/yourusername/annotree.git
cd annotree
uv pip install -e .

🚀 Usage

Command Line

# Generate tree in current directory
annotree

# Specify output file
annotree -o structure.txt

# Use specific ignore file
annotree -i .gitignore

# Limit depth
annotree -l 3

# Show directories only
annotree -d

# Customize annotation alignment
annotree -a 60 -o tree.txt

Python API

from pathlib import Path
from annotree import tree

# Basic usage
tree(Path.cwd(), output_file="tree.txt")

# Custom options
tree(
    Path.cwd(),
    ignore_file=".treeignore",
    level=3,
    output_file="tree.txt",
    annotation_start=50
)

# Directories only
tree(Path.cwd(), limit_to_directories=True, output_file="dirs_only.txt")

📄 .treeignore

Create a .treeignore file in your project root to filter files specifically for Annotree (independent of .gitignore):

__pycache__/
*.pyc
.pytest_cache/
.venv/
node_modules/
dist/
build/
  • If .treeignore exists, Annotree uses it automatically.
  • Otherwise, .gitignore is respected if present.

🎨 Example Output

my-project
├─ src                                  # Main application source code
│   ├─ __init__.py                      # Package initialization
│   ├─ main.py                          # Application entry point
│   └─ utils                            # Utility functions and helpers
│       ├─ __init__.py                  # Utils package initialization
│       └─ helpers.py                   # Common helper functions
├─ tests                                # Test suite
│   └─ test_main.py                     # Tests for main module
└─ README.md                            # Project documentation

2 directories, 6 files

🤝 Contributing

Contributions welcome! Feel free to submit a Pull Request or open an Issue.


📜 License

MIT License — see LICENSE for details.


🔗 Links

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

annotree-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

annotree-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: annotree-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for annotree-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1f34761fc22bed484ac60713a7fa1e315610124303afab9a35d91b2948a6fdf3
MD5 fa277413c434d358923d9eaceb7ebbb9
BLAKE2b-256 00891123bd97bae021cdd938904f21785505c22406f5fb4d3d7f9429d20d3f27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: annotree-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for annotree-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e45b0a47d23aa09cc4f21ba6ae93c2043803871f3a52375c235a0e0097297f7
MD5 1b6d4c75072aa98087f3bb1c389001ce
BLAKE2b-256 4d932c7da5ca2260d0dd025bf5b5444bcfbacac05e70aa57d9a07e27544fda12

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