Directory tree visualiser & syntax‑highlighted code bundler (PDF/DOCX)
Project description
mydir 📂✨
A fast directory‑tree visualiser and syntax‑highlighted code‑bundle exporter
(PDF / DOCX) — perfect for hand‑offs, audits and documentation.
Table of Contents
- Features
- Installation
- Quick Start — CLI
- Quick Start — Python API
- Code Bundle Export
- Advanced Usage
- Contributing & Development
- License
Features
| Category | Highlights |
|---|---|
| Tree ▶️ | folders‑first / files‑first, reverse sort, depth limit, glob ignore rules, human‑readable sizes |
| Export 📄 | Tree → txt, md, JSON (for tooling), forthcoming Mermaid |
| Bundle 🗒 | Syntax‑highlighted PDF & DOCX of every text file in the project (keeps folder ordering) |
| Extras 🔌 | rich console colours (auto), Pygments themes, WeasyPrint zoom, A4/Letter page selection |
| Dev 🛠 | 100 % typed, ruff/black formatted, pytest + tox matrix ready |
Installation
# core (tree printer only)
pip install mydir
# PDF export (adds WeasyPrint)
pip install "mydir[pdf]"
# DOCX export
pip install "mydir[doc]"
# everything
pip install "mydir[pdf,doc]"
Windows: WeasyPrint needs the GTK‑Cairo runtime – see the official docs for a one‑time setup.
Quick Start — CLI
# Print current directory (folders first)
mydir tree .
# Include file sizes, files first, save to Markdown
mydir tree src --show-sizes --files-first -o tree.md
# Bundle the whole repo into a PDF (A4, 300 DPI, 80 % zoom)
mydir bundle . --pdf project.pdf --pdf-dpi 300 --pdf-scale 0.8
Run mydir tree --help or mydir bundle --help for all flags.
Quick Start — Python API
from mydir import mydir
tree = (
mydir(root="src")
.ignore("*.log", "__pycache__")
.max_depth(2)
.show_sizes_on()
)
print(tree.build_tree_str()) # → console
tree.save("tree.md") # → Markdown code‑block
tree.export_code_pdf("code.pdf") # → highlighted PDF
Code Bundle Export
| Format | Extra install | Notes |
|---|---|---|
pip install "mydir[pdf]" |
WeasyPrint under the hood; supports --pdf-scale, DPI & page size |
|
| DOCX | pip install "mydir[doc]" |
Uses python‑docx; retains syntax colours via inline styles |
Both exports walk the project, guess lexers with Pygments, and embed file‑path headings for easy navigation.
Advanced Usage
# Reverse alphabetical, ignore build artefacts
mydir tree . --reverse --ignore dist build "*.egg-info"
# Generate JSON (parseable) via Python
from json import loads
json_lines = loads(mydir(root=".").to_json())
Contributing & Development
git clone https://github.com/your‑org/mydir
cd mydir
python -m pip install -e ".[dev,pdf,doc]" # dev + all extras
pre-commit install # ruff / black / mypy
pytest -q # run tests
tox # full matrix
python -m build && twine upload --repository testpypi dist/*
We follow semantic versioning and the Conventional Commits spec for changelogs.
License
This project is licensed under the MIT License – see LICENSE for details.
Project details
Release history Release notifications | RSS feed
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 mydir-1.0.3.tar.gz.
File metadata
- Download URL: mydir-1.0.3.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
319e556cec3fb6214b6381dbf1bb8387b8de44dd6279b25a5ead35a694ebbd03
|
|
| MD5 |
9777fa7112b9c21e90ab43f5466507c4
|
|
| BLAKE2b-256 |
878039494ffa8aa36cde30894634cb4f254e7c15e8d410111bc222bdb0d62300
|
File details
Details for the file mydir-1.0.3-py3-none-any.whl.
File metadata
- Download URL: mydir-1.0.3-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3627176f0db51490c1238c34e710bf6c2625c6d2ba75a828efdb9a4573c3409b
|
|
| MD5 |
f382eaa182769cc447a98067d1bb01ef
|
|
| BLAKE2b-256 |
b7c73e8316f0104cad8b32e867441feae95bee70193ae4ecda46d6b244470a07
|