Thank you for your interest in contributing to Janus! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Coding Standards
- Testing Guidelines
- Pull Request Process
- Reporting Bugs
- Feature Requests
- Documentation
We are committed to providing a welcoming and inclusive environment for all contributors. Please be respectful and considerate in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/yourusername/janus.git cd janus - Add the upstream remote:
git remote add upstream https://github.com/original/janus.git
- Rust 1.70.0 or later
- Cargo (comes with Rust)
- Docker (optional, for integration tests)
-
Install Rust from rustup.rs:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install additional tools:
rustup component add rustfmt clippy cargo install cargo-audit cargo-watch
-
Build the project:
cargo build
-
Run tests:
cargo test
For continuous testing during development:
cargo watch -x check -x test -x runWe welcome various types of contributions:
- Bug fixes: Fix issues reported in the issue tracker
- Features: Implement new functionality
- Documentation: Improve or add documentation
- Tests: Add or improve test coverage
- Performance: Optimize existing code
- Examples: Create examples demonstrating usage
- Check the issue tracker for existing issues
- For major changes, open an issue first to discuss your approach
- Make sure your idea aligns with the project's goals
We follow the official Rust Style Guide. Key points:
-
Formatting: Use
rustfmtfor code formattingcargo fmt
-
Linting: Use
clippyfor lintingcargo clippy --all-targets --all-features -- -D warnings
-
Naming Conventions:
- Use
snake_casefor functions, variables, and modules - Use
PascalCasefor types and traits - Use
SCREAMING_SNAKE_CASEfor constants
- Use
-
Documentation:
- Add doc comments (
///) for all public APIs - Include examples in doc comments where appropriate
- Use
//!for module-level documentation
- Add doc comments (
- Write idiomatic Rust code
- Prefer immutability where possible
- Use meaningful variable and function names
- Keep functions small and focused
- Avoid unnecessary complexity
- Handle errors appropriately (avoid unwrap in library code)
/// Processes an RDF triple and returns the subject.
///
/// # Arguments
///
/// * `triple` - The RDF triple to process
///
/// # Returns
///
/// The subject of the triple as a string
///
/// # Examples
///
/// ```
/// use janus::process_triple;
///
/// let subject = process_triple(triple)?;
/// assert_eq!(subject, "http://example.org/subject");
/// ```
///
/// # Errors
///
/// Returns an error if the triple is malformed.
pub fn process_triple(triple: &Triple) -> Result<String> {
triple.subject()
.map(|s| s.to_string())
.ok_or_else(|| Error::Query("Invalid triple".to_string()))
}-
Unit Tests: Place in the same file as the code being tested
#[cfg(test)] mod tests { use super::*; #[test] fn test_function_name() { // Test code here } }
-
Integration Tests: Place in the
tests/directoryuse janus::*; #[test] fn test_integration() { // Integration test code }
-
Doc Tests: Include examples in documentation
/// ``` /// use janus::function; /// assert_eq!(function(), expected); /// ```
# Run all tests
cargo test
# Run specific test
cargo test test_name
# Run tests with output
cargo test -- --nocapture
# Run integration tests
cargo test --test '*'
# Run with coverage
cargo llvm-cov --html- Aim for at least 80% code coverage
- All public APIs must have tests
- Include both positive and negative test cases
- Test edge cases and error conditions
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes following the coding standards
-
Run the full test suite:
cargo test --all-features cargo clippy --all-targets --all-features cargo fmt --all -- --check -
Update documentation if needed
-
Commit your changes with clear, descriptive messages:
git commit -m "Add feature X that does Y"
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests where appropriate
- Use conventional commits format:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions/changesrefactor:for code refactoringperf:for performance improvementschore:for maintenance tasks
Example:
feat: add support for MQTT stream sources
- Implement MQTT client integration
- Add configuration options for broker connection
- Include tests for MQTT functionality
Closes #123
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
-
Fill out the PR template with:
- Description of changes
- Related issue numbers
- Testing performed
- Breaking changes (if any)
-
Wait for review and address feedback
- Maintainers will review your PR
- Automated checks must pass (CI/CD)
- At least one maintainer approval is required
- Address review comments promptly
- Keep PR scope focused and manageable
- Squash commits if requested
- Check if the bug has already been reported
- Verify it's reproducible with the latest version
- Collect relevant information
Create an issue with the following information:
**Description**
A clear description of the bug.
**Steps to Reproduce**
1. Step one
2. Step two
3. ...
**Expected Behavior**
What you expected to happen.
**Actual Behavior**
What actually happened.
**Environment**
- OS: [e.g., Ubuntu 22.04]
- Rust version: [e.g., 1.70.0]
- Janus version: [e.g., 0.1.0]
**Additional Context**
Any other relevant information, logs, or screenshots.We welcome feature requests! Please:
- Check if the feature has already been requested
- Provide a clear use case
- Explain the expected behavior
- Consider implementation challenges
- Be open to discussion and alternatives
- Code Documentation: Doc comments in source code
- API Documentation: Generated from doc comments
- User Guide: High-level usage documentation
- Architecture: Design decisions and system overview
- Examples: Practical usage examples
- Use clear, concise language
- Include examples where helpful
- Keep documentation up-to-date with code changes
- Use proper markdown formatting
- Link to related documentation
# Build and open documentation
cargo doc --open --no-deps
# Build with all features
cargo doc --all-features --openIf you have questions about contributing, feel free to:
- Open an issue with the "question" label
- Contact the maintainers at mailkushbisen@gmail.com
- Check existing issues and discussions
By contributing to Janus, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Janus!