The Code Formatter is a powerful command-line tool developed in Rust, designed to parse and format code from specific programming languages. This formatted code is then ready to be fed into Large Language Models (LLMs) for further processing. The tool emphasizes accuracy and efficiency in preparing code data for machine learning applications.
- Targeted Language Parsing: Focuses on specific programming languages, ensuring that the parsing rules are optimized for accuracy.
- Formatting for LLMs: Prepares code in a format that is ideal for ingestion by language models, facilitating better understanding and processing.
- Command-Line Flexibility: Offers customizable options to handle different formats and requirements directly from the command line.
Before you install and run this project, make sure you have the following installed:
- Rust Programming Language (official installation guide)
- Cargo (Rust's package manager, included with Rust installations)
- Tokio (for asynchronous operations, included in the project's dependencies)
To install the project parser, follow these steps:
-
Clone the repository:
git clone https://github.com/charslee013/code_parser.git cd code_parser -
Build the project using Cargo:
cargo build --release
-
The executable will be located in
./target/release/. You can run it directly or add it to your PATH for easier access.
To operate the Code Formatter, use the following command format in the directory containing the executable:
cargo run -- [OPTIONS]Detailed command-line options are provided to customize the tool's operation:
❯ cargo run -- --help
Parses code files based on specified languages and formats output.
USAGE:
code_parser [OPTIONS]
OPTIONS:
-h, --help Print help information 📖
-l, --language <language> Specifies the programming language file extension to parse 🛠️
-o, --output <output> Optional output file to store the results 🗂️
-p, --path <path> The root path to start scanning for code files 📁
-V, --version Print version information ℹ️
--with-test Includes files and folders containing 'test' in their names 🔍
-
Parse Python files in the current directory and print formatted output:
cargo run -- -l py
-
Parse JavaScript files in a specified directory and save output to a file:
cargo run -- -l js -p /path/to/directory/ -o output.txt
You can configure the project parser by editing the source code:
- Modify
src/main.rsto change default settings or add new command-line options. - Update
src/content_formatter.rsto adjust the formatting style based on language. - Edit
src/file_walker.rsto change the rules for file inclusion.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.