A powerful, extensible code formatter library for multiple languages with a clean API interface.
Documentation | Crates.io | GitHub | Changelog
Features
- Multi-language Support: Format code in multiple languages (currently supports JavaScript)
- Extensible Architecture: Easily add support for additional languages
- Clean API: Simple and intuitive API for integration into applications
- Error Handling: Robust error handling with detailed error messages
- Formatting Statistics: Get detailed statistics about formatting operations
- Dry Run Mode: Check which files need formatting without modifying them
- Directory Processing: Format entire directories with a single call
- Customizable: Designed to be easily customized for specific needs
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Usage
use ;
use Path;
// Format a single file
// Format all supported files in a directory
Error Handling
Neatify provides detailed error types for robust error handling:
use ;
use Path;
Adding New Formatters
Neatify is designed to be easily extensible. To add support for a new language:
- Implement the
Tokenizertrait for your language - Implement the
Formattertrait for your language - Register your formatter in the
get_formatter_for_filefunction
See the CONTRIBUTING.md guide for more detailed instructions.
Development
Prerequisites
- Rust 1.56 or higher
- Cargo
Building
# Clone the repository
# Build the project
# Run tests
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Please read our Contributing Guidelines before submitting a pull request.
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Supported Languages
Currently, Neatify supports the following languages:
- JavaScript (.js, .mjs, .cjs)
Planned Support
The following languages are planned for future releases:
- TypeScript
- Rust
- Python
- HTML/CSS
- JSON
- YAML
Acknowledgments
- Inspired by various code formatters like Prettier and rustfmt
- Thanks to all contributors who have helped shape this project