Contributing to phylobuild
Source:CONTRIBUTING.md
Thank you for your interest in contributing to phylobuild! This document provides guidance for developers who want to build, test, and contribute to the package.
Prerequisites
You’ll need the following R packages for development:
install.packages(c("devtools", "roxygen2", "testthat", "pkgdown", "usethis"))Development Workflow
Loading the Package for Development
Use devtools::load_all() to load the package source code without installing it. This is the fastest way to test changes during development:
# From the package root directory
devtools::load_all()
# Now you can use package functions directly
data(primates)
tree <- fast_nj(primates)After making changes to R code, simply run load_all() again to reload.
Note: If you modify C++ code in src/, you’ll need to recompile:
devtools::load_all(recompile = TRUE)Running Tests
Run the test suite with:
devtools::test()Or run specific test files:
devtools::test(filter = "fast_nj")From the terminal:
Updating Documentation
After modifying roxygen2 comments (the #' blocks), regenerate the .Rd files:
devtools::document()This also updates the NAMESPACE file.
Building the pkgdown Website
Build the documentation website locally:
pkgdown::build_site()The site will be generated in the docs/ directory. Open docs/index.html in a browser to preview.
To build just specific parts:
pkgdown::build_home() # Just the home page
pkgdown::build_reference() # Just the function reference
pkgdown::build_articles() # Just the vignettesBuilding and Checking the Package
Regenerating Example Data
If you need to regenerate the example datasets:
source("data-raw/make_example_data.R")This recreates data/primates.rda and data/sim_100.rda.
Project Structure
phylobuild/
├── R/ # R source files
│ ├── phylobuild.R # Main fast_nj() function
│ ├── RcppExports.R # Auto-generated Rcpp bindings
│ └── data.R # Dataset documentation
├── src/ # C++ source files (decenttree library)
│ ├── phylobuild.cpp # R/C++ interface
│ ├── starttree.cpp # Algorithm registry
│ ├── bionj2.cpp # NJ/BIONJ implementations
│ └── ...
├── data/ # Package datasets (.rda files)
├── data-raw/ # Scripts to generate datasets
├── man/ # Documentation (.Rd files, auto-generated)
├── tests/testthat/ # Unit tests
├── vignettes/ # Long-form documentation
├── inst/
│ ├── CITATION # Citation information
│ └── benchmarks/ # Benchmark scripts
└── _pkgdown.yml # Website configuration
Common Tasks
Adding a New Function
- Add the function to an
.Rfile inR/ - Add roxygen2 documentation above the function
- Run
devtools::document()to generate the.Rdfile - Add tests in
tests/testthat/ - Run
devtools::test()to verify
Modifying C++ Code
- Edit files in
src/ - Run
devtools::load_all(recompile = TRUE) - If you add new exported functions, run
Rcpp::compileAttributes() - Run
devtools::check()to ensure it compiles on a clean build
Updating the Vignette
- Edit
vignettes/phylobuild.Rmd - Preview with
devtools::build_vignettes() - Rebuild the pkgdown site with
pkgdown::build_site()
Code Style
- Use roxygen2 for all documentation
- Follow the tidyverse style guide where practical
- Include examples in function documentation
- Write tests for new functionality
Getting Help
- Open an issue on GitHub for bugs or feature requests
- See the pkgdown site for documentation