Skip to main content

A tool for mapping directory structures

Project description

TreeMapper

Build Status
PyPI
License

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 [directory_path] [-i IGNORE_FILE] [-o OUTPUT_FILE] [--no-git-ignore]
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

Example Commands

  1. Analyze the current directory, respecting .gitignore and .treemapperignore:
python -m treemapper .
  1. Analyze a specific directory with a custom ignore file:
python -m treemapper ./my_project -i custom_ignore.txt
  1. 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

treemapper-0.0.8.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

treemapper-0.0.8-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file treemapper-0.0.8.tar.gz.

File metadata

  • Download URL: treemapper-0.0.8.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for treemapper-0.0.8.tar.gz
Algorithm Hash digest
SHA256 8ef699835a3f80537df26977a3150889e42f71c9cfe130011211a5972c4f9f4c
MD5 3f8d2ee17d1dcb2ab19c32e573af9fbe
BLAKE2b-256 526c5975afae892e87b6f6aa7b7f26f407d6874791645a9574d0fea69dc2ede2

See more details on using hashes here.

File details

Details for the file treemapper-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: treemapper-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for treemapper-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9763cdde1cfa2a367056042e9620b4885d35bd26745eaf84f21b3fc187491822
MD5 2c28a3f372755b5451d181ca502191f2
BLAKE2b-256 67c3390b559e76980ed068cecbe1212cb74d11821c832b3605d79229188782ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page