- Comprehensive Documentation: Automatically scans a directory and generates a Markdown document detailing the directory layout and file contents.
- Syntax Highlighting: Uses language detection based on file extensions for enhanced readability in Markdown code blocks.
- Token and Size Statistics: Displays estimated token counts and file size metrics for insights into the generated document.
- .gitignore Integration: Honors .gitignore files, letting you exclude specific files or directories.
- Output Splitting: Can split the output into multiple files if the generated document exceeds a specified size.
- Flexible Modes: Optionally generate structure-only documentation or include file contents.
- Codebase Reconstruction: Rebuild a directory and its files from a dirdoc-generated Markdown document. Binary files are recreated as empty placeholders.
There is an example project in this repo to see the output of dirdoc.
You can see the full example output here:
https://github.com/ChrisNourse/dirdoc/tree/main/example_project/example_project_documentation.md
Below is a sample of it:
# Documentation Summary
The output is a Markdown document summarizing a directory’s structure and file contents. It begins with token and size statistics, followed by a hierarchical view of the directory layout. For each file (unless omitted in structure-only mode), its contents are included in fenced code blocks with optional language annotations and metadata like file size, forming a complete, self-contained reference.
Token Size: 3289
# Directory Documentation:
## Structure
```
📄 example_.gitignore
📄 example_Makefile
📄 example_README.md
📄 example_project_documentation.md
📁 src/
├── 📄 example_main.c
├── 📄 example_utils.c
├── 📄 example_utils.h
📁 tests/
├── 📄 example_test_utils.c
```
# Contents
### 📄 src/example_main.c
```c
/**
* Main.c - Entry point for the sample application
*
* This file demonstrates a simple C application with comments,
* function declarations, and basic program structure.
*/
#include <stdio.h>
#include "utils.h"
// Application version
const char* VERSION = "1.0.0";
/**
* Main entry point for the application
*/
int main(int argc, char *argv[]) {
printf("Sample Application v%s\n", VERSION);
```Visit the GitHub Releases page and download the binary for your operating system.
To conveniently run dirdoc from any folder on your system, choose one of the following methods:
- Option 1: Copy the compiled binary to a directory in your PATH (e.g.,
/usr/local/bin). Ensure you have either runmake(which places the binary inbuild/dirdoc) or downloaded the release file and are currently in the folder that contains thedirdocexecutable:sudo cp build/dirdoc /usr/local/bin/dirdoc # adjust the path if your binary is elsewhere - Option 2: Add the folder containing
dirdocto your PATH. For example, if you place it in~/dirdoc, add the following to your~/.bashrcor~/.bash_profile:Then reload your profile:export PATH="$PATH:$HOME/dirdoc"
source ~/.bashrc
- Option 1: Copy
dirdoc.exeto a directory already in your PATH (e.g.,C:\Windows\System32). - Option 2: Add the folder containing
dirdoc.exeto your PATH environment variable:- Open System Properties (Right-click This PC > Properties > Advanced system settings).
- Click Environment Variables.
- Edit the Path variable and add the folder containing
dirdoc.exe. - Click OK to apply.
Pre-built binaries for dirdoc are available in the GitHub Releases section. Download the binary.
-
macOS, Linux, BSD:
Ensure the binary is executable. If needed, run:chmod +x dirdoc
-
Windows:
Obtain the binary from GitHub Releases, you may need to rename it by appending.exe(e.g.,dirdoc→dirdoc.exe) for proper execution.
Once prepared, you can run the binary directly:
dirdoc --help- Windows:
dirdoc.exe --helpAfter installation, run the application to display the help message:
dirdoc --help-
Generate full documentation:
dirdoc /path/to/dir
-
Specify a custom output file:
dirdoc -o custom_documentation.md /path/to/dir
-
Ignore .gitignore rules:
dirdoc --no-gitignore /path/to/dir
-
Generate structure-only documentation:
dirdoc --structure-only /path/to/dir
-
Enable split output with a custom size limit:
dirdoc -sp /path/to/dir dirdoc -sp -l 10 /path/to/dir
-
Include .git folders in the documentation:
dirdoc --include-git /path/to/dir
-
Reconstruct a codebase from documentation: Binary files will be restored as empty files.
dirdoc --reconstruct -o ./restored project_documentation.md
dirdoc is ideal for:
- Packaging an entire codebase into a single document for LLM analysis.
- Sharing a self-contained reference of your codebase with collaborators.
- Quickly debugging or reviewing a project with both structure and contents in one file.
- Generating documentation that is easy to inspect, share, or version-control.
I found out about both of these after I made the first version of dirdoc. The main difference between the alternatives is the dependencies and portability. I want dirdoc to be as simple as possible to get up and running. No special environments or any other dependencies. Completely portable.
- https://github.com/yamadashy/repomix
- Awesome tool. Has a ton of neat features including a webpage!
- https://github.com/cyclotruc/gitingest
- Beautiful implementation. Also awesome website.
Contributions are welcome! Please open issues or submit pull requests with your suggestions or improvements.
This project is licensed under the MIT License. See the LICENSE file for details.
- Built with Cosmopolitan Libc.
- For more on the Cosmo projects, visit:
- The code is human guided written by AI. Thanks Claude and chatGPT!
- The logo is human generated. Thanks Whit!
