Skip to main content

Extracts and combines all code from a project into a markdown or txt file.

Project description

Code to Text

A tool to extract all code from a project into a single markdown or text file. Useful for inputting code into large language models.

Installation

Install the package using pip:

pip install code-to-text

Usage Extract code from the current directory into a file named all_code.txt:

all_code

Specify a directory to extract code from and a file to write the code to:

all_code --dir_path path/to/my/directory --output_path my_output_file.txt

Specify the file extensions to consider as code files:

all_code --code-extensions py java js cpp c rb go rs

Specify the files and directories to exclude:

code_extractor --exclude-files init.py setup.py --exclude-dirs .git __pycache__ dist

By default, code_extractor uses a set of common code file extensions, excludes a list of common files (like init.py and setup.py), and excludes a list of common directories (like .git and pycache). These defaults are defined in main.py, and you can change them by editing the file. For example, to change the default code file extensions, edit the DEFAULT_CODE_EXTENSIONS variable:

DEFAULT_CODE_EXTENSIONS = ['py', 'java', 'js', 'cpp', 'c', 'rb', 'go', 'rs']

To change the default files to exclude, edit the DEFAULT_EXCLUDE_FILES variable:

DEFAULT_EXCLUDE_FILES = ['__init__.py', 'setup.py', 'README.md']

And to change the default directories to exclude, edit the DEFAULT_EXCLUDE_DIRS variable:

DEFAULT_EXCLUDE_DIRS = ['.git', '__pycache__', 'dist']

Please remember to maintain good security practices and not edit or share the main.py file if it contains sensitive information.

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

code_to_text-0.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

code_to_text-0.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

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