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:
all_code --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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file code_to_text-0.2.tar.gz
.
File metadata
- Download URL: code_to_text-0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c2428edf41490d6e6187b3b190c882d598ec4acff31094d56081ff8841cb3fe |
|
MD5 | 6e9d3b072436eb131d6ffea2fe9dce54 |
|
BLAKE2b-256 | 8d157342c05617a6b96c2738c404fa8486d661066c88a007612b4e00cd10fb15 |
Provenance
File details
Details for the file code_to_text-0.2-py3-none-any.whl
.
File metadata
- Download URL: code_to_text-0.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f29d33d3c70f993faa8c365ce711f6f9659af4f2f7d896dd9f2f27d5dd85cec |
|
MD5 | d40ba4c175ebe930f48e8d0274279ca7 |
|
BLAKE2b-256 | a457a99f6f8920ec644cbee5298adb680f6385490c8179acecbd3385d6d2f98e |