A tool for mapping directory structures
Project description
TreeMapper
TreeMapper is a Python tool designed to convert directory structures and file contents into a YAML format, primarily for use with Large Language Models (LLMs). It helps in codebase analysis, project documentation, and interacting with AI tools by providing a readable representation of your project’s structure.
Key Features
- Converts directory structures into a YAML format
- Captures file contents and includes them in the output
- Supports
.gitignore
and custom ignore files (.treemapperignore
) - Easy-to-use CLI tool with flexible options for input and output paths
- Works cross-platform (Linux, macOS, and Windows)
Installation
TreeMapper requires Python 3.9 or higher.
You can install TreeMapper using pip:
pip install treemapper
Quick Start
To quickly generate a YAML representation of the current directory and save it to output.yaml
, run:
treemapper . -o output.yaml
Usage
TreeMapper can be run from the command line with the following options:
treemapper [-i IGNORE_FILE] [-o OUTPUT_FILE] [--no-git-ignore] [-v VERBOSITY] [directory_path]
Option | Description |
---|---|
directory_path |
The directory to analyze (default: current directory) |
-i, --ignore-file |
Path to a custom ignore file |
-o, --output-file |
Path for the output YAML file (default: ./directory_tree.yaml ) |
--no-git-ignore |
Disable git-related default ignores |
-v, --verbosity |
Set verbosity level (0: ERROR, 1: WARNING, 2: INFO, 3: DEBUG) |
Example Commands
- Analyze the current directory, respecting
.gitignore
and.treemapperignore
:
python -m treemapper .
- Analyze a specific directory with a custom ignore file:
python -m treemapper ./my_project -i custom_ignore.txt
- Output the YAML representation to a different file:
python -m treemapper ./my_project -o project_structure.yaml
Example Output
name: example_directory
type: directory
children:
- name: file1.txt
type: file
content: |
This is the content of file1.txt
- name: subdirectory
type: directory
children:
- name: file2.py
type: file
content: |
def hello_world():
print("Hello, World!")
Configuration
You can use a .treemapperignore
file in your project directory to exclude specific files or directories from the YAML output. The format is similar to .gitignore
.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
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
File details
Details for the file treemapper-0.0.9.tar.gz
.
File metadata
- Download URL: treemapper-0.0.9.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3277bca674e7c8b09af25dabd1a741b647c1f3c84b7ff90561baddc3289c33e |
|
MD5 | ffa2ee59a6979622f0483db6a1aca260 |
|
BLAKE2b-256 | 1d0c9d3a5e8edd6d2f7daacd3fdf962276afbd0cfbaaf3710bfb0a9ed8c42b84 |
File details
Details for the file treemapper-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: treemapper-0.0.9-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | facda379d3adbf8c7ef65dd2ef76c1677ad26132f32273c2ebe2c69c3a5489c0 |
|
MD5 | f23da69ad64080b5a759e87e2efc5984 |
|
BLAKE2b-256 | 08e6dd08c022eeb602eedbe181a383dafe57709462d70611bca20a2be8598cf4 |