Export ExamplesΒΆ
Practical recipes for exporting directory structures. For a per-format reference, see Export Formats.
Exporting to Each FormatΒΆ
recursivist export --format md # structure.md
recursivist export --format json # structure.json
recursivist export --format html # structure.html
recursivist export --format txt # structure.txt
recursivist export --format svg # structure.svg
recursivist export --format rst # structure.rst
Several at once:
Statistics in ExportsΒΆ
recursivist export --format md --sort-by-loc
recursivist export --format html --sort-by-size
recursivist export --format json --mtime # show mtime, keep order
recursivist export --format txt --sort-by-loc --size --mtime # sort by LOC, show all three
A Markdown export with --sort-by-loc:
# π my-project (1262 lines)
- π `README.md` (124 lines)
- π `setup.py` (65 lines)
- π `requirements.txt` (18 lines)
- π **src** (1055 lines)
- π `main.py` (245 lines)
- π `utils.py` (157 lines)
- π **tests** (653 lines)
- π `test_main.py` (412 lines)
- π `test_utils.py` (241 lines)
Output Location and FilenameΒΆ
recursivist export --format md --output-dir ./docs # ./docs/structure.md
recursivist export --format json --prefix my-project # my-project.json
recursivist export --format html --output-dir ./docs --prefix tree # ./docs/tree.html
Filtered and Depth-Limited ExportsΒΆ
# Exclude directories and extensions
recursivist export --format md --exclude node_modules --exclude .git --exclude build --exclude-ext .pyc --exclude-ext .log
# Top-level overview only
recursivist export --format md --depth 1
# Export a subdirectory directly
recursivist export src --format html --prefix source-structure
# Full paths (handy for JSON consumed by other tools)
recursivist export --format json --full-path
Processing JSON with jqΒΆ
Export to JSON with metrics, then analyze with jq. With a detail flag, each file is an object carrying path, loc, and/or size:
# Ten files with the most lines of code
jq -r '.structure | .. | objects | select(has("_files")) | ._files[]
| select(type=="object" and has("loc")) | [.loc, .path] | @tsv' \
structure.json | sort -nr | head -10
# Count files by extension
jq -r '.structure | .. | objects | select(has("_files")) | ._files[]
| select(type=="object") | (.path | split(".") | .[-1]) | ascii_downcase' \
structure.json | sort | uniq -c | sort -nr