codepress
Transforming code into clean, readable text with precision and style.
Table of Contents
Introduction
codepress is a powerful command-line tool designed to transform your codebase into clean, readable text. Whether you're preparing documentation, creating code snippets for tutorials, or simply organizing your projects, codepress ensures that your code is presented with precision and style. Additionally, it provides token usage analysis to help you understand the size and complexity of your codebase.
Features
- Recursive File Processing: Walk through directories to process multiple files effortlessly.
- Flexible Output Formats: Generate output in plain text or JSON formats.
- Customizable Output Styles: Define how your code and file information are formatted.
- Gitignore Support: Automatically respect
.gitignorepatterns to exclude unwanted files. - Line Truncation: Limit the number of lines read from each file to manage large files efficiently.
- Token Usage Analysis: Inspect and visualize token counts for files in your project.
- Verbose Logging: Get detailed logs to monitor the processing flow.
- Extensible: Easily integrate with other tools and workflows.
Installation
Ensure you have Python 3.11 or higher installed.
-
Clone the Repository
git clone https://github.com/allen2c/codepress.git cd codepress
-
Install Dependencies
Using Poetry:
poetry installAlternatively, using
pip:pip install -r requirements.txt
-
Build and Install
poetry build poetry install
Usage
Once installed, you can use codepress via the command line.
Basic Usage
codepress [OPTIONS] [PATH]
- PATH: The directory or file to process. Defaults to the current directory (
.).
Options
-
--ignore TEXTPatterns to ignore. Can be specified multiple times. -
--ignore-hidden / --no-ignore-hiddenIgnore hidden files and directories. Default is--ignore-hidden. -
--enable-gitignore / --no-enable-gitignoreEnable.gitignorepatterns. Default is--enable-gitignore. -
--truncate-lines INTEGERNumber of lines to read from each file. Default is5000. -
--output-format [text|json]Output format. Choices aretextorjson. Default istext. -
--output-style TEXTOutput style. Default iscodepress:DEFAULT_CONTENT_STYLE. Skip style if output format isjson. -
--output PATHOutput file. Defaults tostdoutif not specified. -
--inspectShow files with total token count and usage summary. -
--verbose / --no-verboseEnable verbose output. Default is--no-verbose. -
--helpShow the help message and exit.
Examples
-
Process the Current Directory
codepress
-
Process a Specific Directory with Verbose Logging
codepress ./my_project --verbose
-
Ignore Specific Patterns
codepress ./my_project --ignore "*.pyc" --ignore "__pycache__/"
-
Output to a File in JSON Format
codepress ./my_project --output-format json --output output.json
-
Limit the Number of Lines Read from Each File
codepress ./my_project --truncate-lines 1000
-
Disable Gitignore Support
codepress ./my_project --no-enable-gitignore
-
Inspect Token Usage
codepress ./my_project --inspect
Configuration
You can customize the output style by modifying or creating your own styles. The default style is defined in codepress/__init__.py as DEFAULT_CONTENT_STYLE. To use a custom style, specify it using the --output-style option in the format module:VARIABLE_NAME.
Example:
codepress ./my_project --output-style mymodule:MY_CUSTOM_STYLE
Ensure that your custom style variable is defined and accessible within the specified module.
Contributing
Contributions are welcome! Whether it's reporting bugs, suggesting features, or submitting pull requests, your support helps make codepress better.
-
Fork the Repository
-
Create a New Branch
git checkout -b feature/YourFeature
-
Make Your Changes
-
Commit Your Changes
git commit -m "Add your message"
-
Push to the Branch
git push origin feature/YourFeature
-
Open a Pull Request
Please ensure your code follows the project's coding standards and that all tests pass.
License
This project is licensed under the MIT License.
Metadata
Release files for codepress 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codepress-0.2.2.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codepress-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.3 kB
Release files / codepress-0.2.2.tar.gz
| Download URL | codepress-0.2.2.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7cafb19a4850ef998e5bbb2094cef5687682f6bd98b5efa70a2b6268b7eba6a
|
|
BLAKE2b-256 checksum How to use checksums |
c562935a8f3e2f98e05b278c0fc9834a0e6bd8f33398a90737daf076ef36a914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.11 Darwin/24.5.0
|
Release files / codepress-0.2.2-py3-none-any.whl
| Download URL | codepress-0.2.2-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f870318a72cb029a682bd9f7510beb802c8644c292e7ae90f661c1f1942a2fe0
|
|
BLAKE2b-256 checksum How to use checksums |
c0b7a1de0b26004d3747502d4eaca4b95f5e982b1bcabae133fc88f322c969fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.11 Darwin/24.5.0
|