Contributing to chapr
Source:CONTRIBUTING.md
Thank you for your interest in contributing to the Chap R SDK! This document provides guidelines and instructions for contributing.
Code of Conduct
Please read and follow our Code of Conduct.
How to Contribute
Reporting Bugs
If you find a bug, please open an issue on GitHub with:
- A clear, descriptive title
- A detailed description of the problem
- Steps to reproduce the issue
- Expected behavior vs. actual behavior
- Your R version and operating system
- Any relevant error messages or logs
Development Setup
This project uses renv for reproducible dependency management.
Getting Started
In R:
# Restore dependencies via renv
renv::restore()
# Load the package for development
devtools::load_all()Development Workflow
# Load package during development
devtools::load_all()
# Run tests
devtools::test()
# Run a single test file
devtools::test_active_file() # In RStudio
testthat::test_file("tests/testthat/test-validation.R")
# Generate documentation
devtools::document()
# Run R CMD check
devtools::check()
# Build vignettes
devtools::build_vignettes()Coding Standards
Style Guide
We follow the tidyverse style guide. Key points:
- Use
snake_casefor function and variable names - Use meaningful, descriptive names
- Keep lines under 80 characters when possible
- Use
<-for assignment, not=
Documentation
- All exported functions must have roxygen2 documentation
- Include
@param,@return,@export, and@examplessections - Examples should be runnable or wrapped in
\dontrun{}
Example:
#' Brief description of the function
#'
#' Longer description if needed.
#'
#' @param x Description of parameter x
#' @param y Description of parameter y
#'
#' @return Description of what the function returns
#'
#' @export
#'
#' @examples
#' my_function(1, 2)
my_function <- function(x, y) {
# Implementation
}Testing
- Write tests for all new functionality
- Place tests in
tests/testthat/ - Follow the naming convention:
test-{source-file-name}.R - Use descriptive test names
Example:
test_that("function_name handles edge case correctly", {
result <- function_name(edge_case_input)
expect_equal(result, expected_output)
})Project Structure
chap_r_sdk/
├── R/ # R source files
│ ├── cli.R # CLI interface functions
│ ├── validation.R # Model validation functions
│ ├── config.R # Configuration management
│ └── ...
├── man/ # Generated documentation (do not edit)
├── tests/
│ └── testthat/ # Test files
├── vignettes/ # Long-form documentation
├── inst/
│ └── testdata/ # Test data files
├── examples/ # Example model implementations
├── DESCRIPTION # Package metadata
└── NAMESPACE # Exports (generated by roxygen2)
Pre-Push Checklist
Before pushing your changes:
- Run
devtools::test()- all tests should pass - Run
devtools::check()- address all errors and warnings - Run
devtools::document()- update documentation - Run
spelling::spell_check_package()- fix any spelling errors - Update NEWS.md if adding user-facing changes