r2md is a simple tool that converts your code repositories into a well-structured Markdown file. Whether you want to document your project, create a readable code overview, or prepare content for training machine learning models, r2md makes the process easy and efficient.
- Code to LLM Made Easy: See entire codebase as single .md file.
- Consolidate Code Snippets: Merge code from multiple directories into a single, organized Markdown file.
- Optional PDF Output: Easily create a PDF version of your codebase for sharing or printing.
- Training Data Preparation: Generate JSON files with prompt and completion pairs for SFT training.
After downloading the r2md binary, place it in your system's PATH to use it from anywhere in the terminal.
Once the binary is installed, you can use the r2md
command followed by various options to customize its behavior.
Convert the current directory into a Markdown file:
r2md
r2md --include 'src/**/*.rs'
r2md --include '**/*.js' --include '**/*.ts'
This will generate a r2md_output.md
file in the current directory.
Process one or more specific directories:
r2md path/to/dir1 path/to/dir2
Process one or more specific urls:
r2md https://github.com/skirdey/boss.git
Exclude certain folders from processing:
r2md -x node_modules -x target
Define a custom name for the output Markdown file:
r2md -o my_documentation.md
Create a PDF version of the Markdown output:
r2md -p
Get detailed output for troubleshooting:
r2md --debug
Create a JSON file with training data using 80 (prompt) /20 (completion) split:
r2md --train-json training_data.json
Use multiple options together:
r2md path/to/dir -x .git -o project_docs.md -p --debug --train-json training.json
-
Generate Markdown from Current Directory:
r2md
Output:
r2md_output.md
-
Generate Markdown and PDF, Excluding
node_modules
:r2md -x node_modules -p
Outputs:
r2md_output.md
andr2md_output.pdf
-
Generate Training JSON from Specific Directories:
r2md src tests --train-json training_data.json
Output:
training_data.json
r2md can be customized using a YAML configuration file (r2md.yml
or r2md.yaml
). This allows you to define additional ignore patterns and other settings.
Example r2md.yml
:
ignore_patterns:
- "temp"
- "backup"
For more options and detailed information, use the help flag:
r2md --help