First off, thanks for taking the time to contribute! 🎉
The following is a set of guidelines for contributing to batless. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
- Code of Conduct
- How Can I Contribute?
- Development Setup
- Pull Request Process
- Coding Standards
- Testing Guidelines
- Documentation
- Issue Guidelines
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
Before creating bug reports, please check the existing issues as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible using our bug report template.
Feature suggestions are welcome! Please use our feature request template and provide:
- A clear description of the feature
- The problem it solves
- Example usage
- Any alternatives you've considered
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure all tests pass
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Rust 1.70+ (latest stable recommended)
- Git
- A terminal/shell
-
Clone the repository
git clone https://github.com/your-username/batless.git cd batless -
Install dependencies
cargo build
-
Run tests
cargo test -
Run the application
cargo run -- --help
# Format code
cargo fmt
# Run linter
cargo clippy
# Run all tests
cargo test
# Run specific test
cargo test test_name
# Run integration tests
cargo test --test integration_tests
# Run coverage (local)
cargo llvm-cov --all-features --workspace report
# Run quality subset
cargo clippy --all-targets --all-features -- -D warnings
cargo machete || true
# Build release version
cargo build --release
# Run with sample file
cargo run -- examples/demo.py --mode=highlight --max-lines=10-
Before submitting:
- Ensure your code compiles without warnings
- Run
cargo fmtto format your code - Run
cargo clippyand fix any issues - Add tests for new functionality
- Update documentation if needed
-
PR Requirements:
- Fill out the PR template completely
- Include a clear description of changes
- Reference any related issues
- Ensure CI checks pass
-
Review Process:
- At least one maintainer review is required
- Address feedback promptly
- Keep the PR up to date with the main branch
- Follow the official Rust Style Guide
- Use
cargo fmtfor consistent formatting - Use
cargo clippyand address all warnings - Prefer explicit types when it improves readability
- Use meaningful variable and function names
- Keep functions focused and small
- Use modules to organize related functionality
- Put tests in the same file as the code they test (for unit tests)
- Put integration tests in the
tests/directory - Document public APIs with rustdoc comments
- Use
Result<T, E>for functions that can fail - Provide meaningful error messages
- Use
?operator for error propagation - Don't use
unwrap()orexpect()in library code - Handle edge cases gracefully
- Prefer streaming over loading entire files
- Use appropriate data structures
- Avoid unnecessary allocations
- Profile before optimizing
- Maintain memory efficiency
- Test all public functions
- Test edge cases and error conditions
- Use descriptive test names
- Keep tests focused and independent
- Use the
#[cfg(test)]attribute for test modules
Example:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_process_file_basic() {
// Test implementation
}
}- Test CLI functionality end-to-end
- Test different operating systems in CI
- Test various file types and edge cases
- Use temporary files for test data
- Aim for high test coverage
- Focus on critical paths and edge cases
- Run coverage reports locally when possible
- Document all public functions and types
- Use rustdoc format (
///or/** */) - Include examples in documentation
- Explain complex algorithms or business logic
- Update README.md for user-facing changes
- Add examples for new features
- Update CHANGELOG.md for all changes
- Keep documentation concise but complete
/// Process a file according to the given configuration.
///
/// # Arguments
///
/// * `file_path` - Path to the file to process
/// * `config` - Configuration for processing
///
/// # Returns
///
/// Returns `FileInfo` containing processed data and metadata.
///
/// # Errors
///
/// Returns an error if the file cannot be read or processed.
///
/// # Examples
///
/// ```
/// let config = BatlessConfig::default();
/// let info = process_file("src/main.rs", &config)?;
/// ```
pub fn process_file(file_path: &str, config: &BatlessConfig) -> Result<FileInfo, Box<dyn std::error::Error>> {
// Implementation
}- Use the bug report template
- Provide minimal reproduction steps
- Include environment details
- Attach relevant files if helpful
- Use the feature request template
- Explain the problem you're trying to solve
- Provide examples of how it would work
- Consider backwards compatibility
- Check existing documentation first
- Use discussions for general questions
- Be specific about what you're trying to achieve
Releases follow semantic versioning:
- MAJOR version for incompatible API changes
- MINOR version for backwards-compatible functionality
- PATCH version for backwards-compatible bug fixes
- Update version in
Cargo.toml - Update
CHANGELOG.md - Create release PR
- Tag release after merge
- GitHub Actions handles the rest
Contributors will be recognized in:
- CHANGELOG.md for significant contributions
- README.md contributors section
- Release notes for major features
- Check the README first
- Look through existing issues
- Start a discussion
- Join our community channels (if available)
By contributing to batless, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to batless! 🦇