Skip to main content

A tool to consolidate repository files into a single file

Project description

repo-to-one-file

License: MIT GitHub Repo stars

repo-to-one-file is a Python tool that consolidates repository files into a single Markdown file. It's designed to create a comprehensive overview of a codebase, which can be particularly useful for documentation or as context for large language models.

Check out the repo here, please star <3
Check out the JavaScript version here

Features

  • Generates a directory structure of the repository
  • Consolidates content of specified file types (.py, .js, .ts, .json, etc.) into a single Markdown file
  • Ignores common non-source files and directories (node_modules, .git, etc.)
  • Configurable maximum line count per file
  • Option to include normally ignored files
  • Prioritizes important files like README, package.json, requirements.txt, etc.

Installation

Using pip:

pip install repo-to-one-file

or

You can install repo-to-one-file directly from GitHub:

pip install git+https://github.com/tonypls/repo-to-one-file.git

For development, clone the repository and install in editable mode:

git clone https://github.com/tonypls/repo-to-one-file.git
cd repo-to-one-file
pip install -e .

Usage

After installation, you can use repo-to-one-file from the command line:

repo-to-one-file

This will create a combined_repo.md file in the current directory.

Options

  • --max-lines: Set the maximum number of lines per file (default: 1000)
  • --include-ignored: Include files that would normally be ignored

Example:

repo-to-one-file --max-lines 2000 --include-ignored

Output Format

The generated Markdown file will have the following structure:

  1. Directory structure of the repository
  2. Content of priority files (README, package.json, requirements.txt, pyproject.toml)
  3. Content of other included files (.py, .js, .ts, .json, etc.)

Each file's content is presented under a header with its relative path and enclosed in a code block with the appropriate language tag.

Ignored Patterns

By default, the tool ignores many common non-source files and directories, including:

  • Version control directories (.git, .svn)
  • Package manager directories and files (node_modules, package-lock.json)
  • Build directories and files (dist, build)
  • Cache directories
  • Log files
  • Environment files
  • OS-generated files

For a full list, please refer to the ignored_patterns list in the __main__.py file.

Development

To set up the development environment:

  1. Clone the repository
  2. Install the package in editable mode: pip install -e .
  3. Install development dependencies: pip install pytest

To run tests (once implemented):

pytest

Contributing

Contributions are welcome! Here are some ways you can contribute:

  1. Implement test cases
  2. Improve error handling and logging
  3. Add support for more file types
  4. Optimize performance for large repositories
  5. Improve documentation and examples

Please feel free to submit issues and pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • This project was inspired by the need to provide concise codebase overviews for large language models.
  • Thanks to all contributors and users of this tool.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repo_to_one_file-1.0.4.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repo_to_one_file-1.0.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file repo_to_one_file-1.0.4.tar.gz.

File metadata

  • Download URL: repo_to_one_file-1.0.4.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for repo_to_one_file-1.0.4.tar.gz
Algorithm Hash digest
SHA256 fce2696d643bf7065ed4156b1c0fb94447ee9cd014101f244d39da295d0feca3
MD5 106becee294e8beae37c3fd97206e282
BLAKE2b-256 23dac5aca4ce0d39fef748787a324b6796f1ad11c85319ab4f85b7d6313d1f6c

See more details on using hashes here.

File details

Details for the file repo_to_one_file-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for repo_to_one_file-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f573a5f16cc23b395beb70d87a193a4ca087d4530019d5809117273cbc9f1f18
MD5 7080a3a0e226820a504551052f2da512
BLAKE2b-256 fd52f1def70b70348953238913992f0f30b26a035758ed45f92c94de4b75ca6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page