This script allows you to export files from a local directory or a Git repository to a Markdown file. Useful for analyzing repositories, documenting projects, or processing content for artificial intelligence applications.
- Process Local Files or Git Repositories.
- Configuration Support: Customize included extensions, excluded directories, and maximum file size via a
config.yamlfile. - Obey
.gitignore: Option to exclude files listed in.gitignore. - Markdown Export: Includes code content and highlighted languages.
- Support for Large-Scale Directories and Files.
- Python 3.8 or higher.
- Additional Dependencies (installed with
pip): pyyaml
-
Clone this Repository or copy the files to your project directory.
-
Install the Dependencies:
pip install -r requirements.txt- Configure the
config.yamlFile:
This file contains the key parameters for execution.
Example Configuration:
max_file_size: 1048576 # Maximum size in bytes (1 MB)
excluded_dirs:
- .venv
- .git
- node_modules
included_extensions:
.py: python
.yaml: yaml
.json: jsonRun the script from the command line with the following options:
Process a local directory:
python3 repo2md.py ./ --output repositoryClone a repository and process its contents:
python3 repo2md.py https://github.com/user/repo.git --git --output repositoryTo exclude files listed in .gitignore:
python3 repo2md.py ./ --output repository --obey-gitignoreExclude additional directories with --exclude-dirs:
python3 repo2md.py ./ --output repository --exclude-dirs dist build| Option | Description |
|---|---|
source |
Local path or URL of a Git repository. |
--config |
YAML configuration file (default: config.yaml). |
--output |
Base name for the generated Markdown file. |
--git |
Indicates that the origin is a Git repository (requires valid URL). |
--exclude-dirs |
List of additional directories to exclude. |
--obey-gitignore |
Respect exclusions defined in the repository's .gitignore. |
This project is licensed under the MIT License.