Export Examples¶
This page provides practical examples of how to use Recursivist's export functionality to save directory structures in various formats.
Basic Export Examples¶
Exporting to Different Formats¶
Markdown Export¶
This creates structure.md
with a markdown representation of the directory structure.
JSON Export¶
This creates structure.json
with a JSON representation of the directory structure.
HTML Export¶
This creates structure.html
with an interactive HTML view of the directory structure.
Text Export¶
This creates structure.txt
with a plain text ASCII tree representation.
React Component Export¶
This creates structure.jsx
with a React component for interactive visualization.
Exporting to Multiple Formats Simultaneously¶
This creates three files: structure.md
, structure.json
, and structure.html
.
Including File Statistics¶
Exporting with Lines of Code Statistics¶
This creates a markdown file with line counts for each file and directory:
# 📂 my-project (4328 lines)
- 📁 **src** (3851 lines)
- 📄 `main.py` (245 lines)
- 📄 `utils.py` (157 lines)
- 📁 **tests** (653 lines)
- 📄 `test_main.py` (412 lines)
- 📄 `test_utils.py` (241 lines)
- 📄 `README.md` (124 lines)
- 📄 `requirements.txt` (18 lines)
- 📄 `setup.py` (65 lines)
Exporting with File Sizes¶
This creates an HTML file with file size information for each file and directory.
Exporting with Modification Times¶
This creates a JSON file that includes modification timestamps for each file and directory.
Combining Multiple Statistics¶
This combines lines of code, file sizes, and modification times in a single export.
Customizing Export Output¶
Custom Output Directory¶
This saves the markdown export to ./docs/structure.md
.
Custom Filename Prefix¶
This creates my-project.json
instead of structure.json
.
Combining Custom Directory and Filename¶
This creates ./documentation/project-structure.html
.
Filtered Exports¶
Exporting with Directory Exclusions¶
This exports a markdown representation excluding the specified directories.
Exporting with File Extension Exclusions¶
This exports a JSON representation excluding files with the specified extensions.
Exporting with Pattern Exclusions¶
This exports an HTML representation excluding JavaScript test files.
Exporting Only Specific Files¶
This exports a markdown representation including only JavaScript files in the src
directory and markdown files.
Exporting with Gitignore Patterns¶
This exports a text representation respecting the patterns in .gitignore
.
Depth-Limited Exports¶
Exporting with Limited Depth¶
This exports an HTML representation limited to 2 levels of directory depth.
Exporting Top-Level Overview¶
This exports a markdown representation showing only the top level of the directory structure.
Full Path Exports¶
JSON Export with Full Paths¶
This exports a JSON representation with full file paths instead of just filenames.
Markdown Export with Full Paths¶
This exports a markdown representation with full file paths.
Specific Project Exports¶
Source Code Documentation with LOC Stats¶
recursivist export \
--format md \
--include-pattern "src/**/*" \
--exclude-pattern "**/*.test.js" "**/*.spec.js" \
--output-dir ./docs \
--prefix source-structure \
--sort-by-loc
This exports a markdown representation of the source code structure with lines of code information for documentation purposes.
Project Overview for README¶
recursivist export \
--format md \
--depth 2 \
--exclude "node_modules .git build dist" \
--prefix project-overview \
--sort-by-size
This creates a concise project overview with file size information suitable for inclusion in a README file.
React Component Export Examples¶
Basic React Component Export¶
This exports a React component to ./src/components/structure.jsx
.
Customized React Component with Statistics¶
recursivist export \
--format jsx \
--include-pattern "src/**/*" \
--exclude "node_modules .git" \
--output-dir ./src/components \
--prefix project-explorer \
--sort-by-loc \
--sort-by-mtime
This exports a filtered React component focused on the source code to ./src/components/project-explorer.jsx
with lines of code and modification time information.
Export for Different Use Cases¶
Documentation Export with Stats¶
recursivist export \
--format "md html" \
--exclude "node_modules .git build dist" \
--exclude-ext ".log .tmp .cache" \
--output-dir ./docs \
--prefix project-structure \
--sort-by-loc
This exports both markdown and HTML representations with lines of code statistics for documentation purposes.
Codebase Analysis Export¶
recursivist export \
--format json \
--full-path \
--exclude "node_modules .git" \
--prefix codebase-structure \
--sort-by-loc \
--sort-by-size
This exports a detailed JSON representation with full paths, line counts, and file sizes for codebase analysis.
Website Integration Export¶
recursivist export \
--format jsx \
--exclude "node_modules .git build dist" \
--output-dir ./website/src/components \
--prefix directory-explorer \
--sort-by-loc \
--sort-by-mtime
This exports a React component with lines of code and modification time data for integration into a website.
Batch Export Examples¶
Multiple Export Configuration Script¶
Here's a shell script to export multiple configurations with statistics:
#!/bin/bash
# Export overview
recursivist export \
--format md \
--depth 2 \
--exclude "node_modules .git" \
--output-dir ./docs \
--prefix project-overview \
--sort-by-loc
# Export detailed structure
recursivist export \
--format html \
--exclude "node_modules .git" \
--output-dir ./docs \
--prefix detailed-structure \
--sort-by-loc \
--sort-by-size
# Export JSON for processing
recursivist export \
--format json \
--full-path \
--output-dir ./data \
--prefix directory-data \
--sort-by-loc \
--sort-by-size
# Export React component
recursivist export \
--format jsx \
--output-dir ./src/components \
--prefix directory-viewer \
--sort-by-loc \
--sort-by-mtime
Project Subdirectory Exports with Stats¶
Here's a script to export structures for each subdirectory with statistics:
#!/bin/bash
# Get all immediate subdirectories
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "node_modules/" ] && [ "$dir" != ".git/" ]; then
dir_name=$(basename "$dir")
echo "Exporting structure for $dir_name..."
recursivist export "$dir" \
--format md \
--output-dir ./docs/components \
--prefix "$dir_name-structure" \
--sort-by-loc \
--sort-by-size
fi
done
Combining with Shell Commands¶
Export and Process with jq¶
Export to JSON with LOC stats and process with jq to count files by type:
# Export with LOC stats
recursivist export --format json --prefix structure --sort-by-loc
# Use jq to analyze LOC data
jq -r '.structure | .. | objects | select(has("_files")) |
._files[] | select(type=="object" and has("loc")) |
{ext: (.path | split(".") | .[-1]), loc: .loc} |
.ext + "," + (.loc | tostring)' structure.json | \
awk -F, '{sum[$1] += $2; count[$1]++}
END {for (ext in sum)
printf "%s files: %d lines in %d files (avg: %.1f lines/file)\n",
ext, sum[$1], count[$1], sum[$1]/count[$1]}' | \
sort -k2 -nr
Export and Include in Documentation¶
# Export with LOC stats to markdown
recursivist export --format md --prefix structure --sort-by-loc
# Create README with project structure
echo "# Project Structure" > README.md
echo "" >> README.md
echo "## Directory Overview" >> README.md
echo "" >> README.md
cat structure.md >> README.md
This creates a README with the project structure including lines of code information.