Thank you for your interest in contributing to tesseract-rs! This document provides guidelines and instructions for contributing.
We use Conventional Commits for our commit messages. This leads to more readable messages that are easy to follow when looking through the project history.
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- build: Changes that affect the build system or external dependencies
- ci: Changes to our CI configuration files and scripts
- chore: Other changes that don't modify src or test files
- revert: Reverts a previous commit
feat: add support for async OCR operations
fix: resolve Windows build issues with HOME environment variable
docs: update README with Windows installation instructions
test: add unit tests for error handling
ci: add commitlint to PR validation
The scope should be the name of the module affected (as perceived by the person reading the changelog generated from commit messages).
Examples:
buildapierrortests
The subject contains a succinct description of the change:
- Use the imperative, present tense: "change" not "changed" nor "changes"
- Don't capitalize the first letter
- No dot (.) at the end
The body should include the motivation for the change and contrast this with previous behavior.
The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit closes.
We use Husky to enforce code quality and commit message standards. To set up the hooks:
- Install Node.js if you haven't already
- Run
./setup-hooks.shornpm installin the project root - The pre-commit and commit-msg hooks will be automatically installed
The hooks will:
- Pre-commit: Check code formatting (rustfmt) and run clippy before allowing commits
- Commit-msg: Validate commit messages against our conventional commit format
If pre-commit checks fail:
- Run
cargo fmtto fix formatting issues - Run
cargo clippyto see warnings and fix them
- Fork the repository and create your branch from
master - If you've added code that should be tested, add tests
- Ensure the test suite passes with
cargo test - Make sure your code follows the Rust style guide with
cargo fmt - Ensure there are no clippy warnings with
cargo clippy - Update the README.md with details of changes if applicable
- Create a Pull Request with a clear title and description
- Clone the repository
- Install Rust (latest stable version)
- Install build dependencies:
- CMake
- C++ compiler
- Node.js (for commit hooks)
- Run
npm installto set up commit hooks - Run
cargo buildto ensure everything compiles - Run
cargo testto run the test suite
- Follow the official Rust Style Guide
- Use
cargo fmtbefore committing - Address all
cargo clippywarnings - Write descriptive variable and function names
- Add comments for complex logic
- Keep functions small and focused
- Write unit tests for new functionality
- Ensure all tests pass before submitting a PR
- Add integration tests for significant features
- Test on Windows, macOS, and Linux if possible
Feel free to open an issue if you have any questions or need clarification on anything!