This file provides guidance to agents when working with code in this repository.
Common workflows are defined in Taskfile.yml (run via Task):
- Install (from repo root):
task install - Build package tarball:
task build - Build CRAN-style tarball:
task build-cran - Generate docs/namespace:
task document - Run tests:
task test(callsdevtools::test()) - Run package checks:
task check(callsdevtools::check()) - Clean build artifacts:
task clean
Single-test workflows:
- Run one test file by filter:
Rscript -e 'devtools::test(filter = "plotting")' - Run one test file directly:
Rscript -e 'testthat::test_file("tests/testthat/test-plotting.R")'
Rust-binding workflows:
- Regenerate extendr wrappers (
R/extendr-wrappers.Rand the Rustextendr_module!):task extendr-document. - Re-vendor Rust dependencies after a
Cargo.tomlbump (refreshessrc/rust/vendor.tar.xz, clearing any stalesrc/.cargo/src/vendorfirst):task vendor-pkgs. - Build for development with debug profile + permissive Cargo flags: set
DEBUG=1(orNOT_CRAN=1) beforetask install.tools/config.Rreads these env vars to switch between CRAN-safe and dev builds, and writessrc/Makevarsfromsrc/Makevars.in.
CI: main CI uses r-lib/actions/check-r-package@v2
(.github/workflows/R-CMD-check.yaml); the docs site uses
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
(.github/workflows/pkgdown.yaml).
eulerr is an R package with an R orchestration layer and a Rust computational
core (via extendr-api), built on top of the eunoia Rust crate.
- User entry points:
euler()andvenn()S3 generics (R/euler.R,R/venn.R) with methods for vectors, data frames, matrices, tables, and lists. - Input normalization: methods convert varied inputs into named overlap
vectors (
R/parse_input.R+ helpers inR/utils.R); combination names are joined by&(e.g.,"A&B&C"). - Fitting pipeline:
fit_diagram()(R/fit_diagram.R) validates input, dispatches to the Rust backend viafit_euler_diagram()(declared inR/extendr-wrappers.R), and computes fit metrics (regionError,diagError,stress). - Numerical engine (Rust):
src/rust/src/lib.rsis a thin extendr shim that converts R inputs into aeunoia::DiagramSpec, runseunoia::Fitter, and returns geometry back to R. The heavy geometry/optimization lives in theeunoiacrate (src/rust/Cargo.tomldepends oneunoia). - Build glue:
configureinvokestools/config.R, which readsDESCRIPTIONSystemRequirements, validates the installedrustcversion, and renderssrc/Makevars{.in,.win.in}→src/Makevars{,.win}. The resulting Makevars runscargo build --manifest-path=./rust/Cargo.tomlto producelibeulerr.a, which is linked intoeulerr.soviasrc/entrypoint.c. - Rendering pipeline:
plot.euler()(R/plot.euler.R) builds diagram data in two phases:setup_geometry()(R/setup_geometry.R) computes polygons/centers/bounds (usespolyclipandpolylabelr).setup_grobs()(R/setup_grobs.R) converts geometry to grid grobs. Returns aneulergramgTree drawn byplot.eulergram()/print.eulergram(). The package ships its own legend grob implementation (R/legend.R) rather than usinggrid::legendGrob.
- Global plotting defaults:
eulerr_options()and.eulerr_env$options(R/eulerr_options.R,R/zzz.R) provide package-wide visual defaults consumed by the plotting code.
- Roxygen2-managed package:
NAMESPACEandman/*.Rdare generated. Update roxygen comments inR/*.Rand runtask document; do not hand-editNAMESPACE. R/extendr-wrappers.Rand the corresponding Rustextendr_module!block are generated byrextendr::document()--- do not hand-edit either side; edit the#[extendr]functions insrc/rust/src/lib.rsand regenerate.README.mdis generated fromREADME.Rmd; editREADME.Rmdfor README changes.- Plotting is implemented with grid grobs (
eulergram), not base graphics. Preserve thesetup_geometry()→setup_grobs()separation when changing plotting behavior. - Combination naming uses
&delimiters acrosseuler(),fit_diagram(),parse_input(), and the Rust side (which splits on&to recover set names). - R style follows
air.toml:line-width = 80,indent-width = 2, spaces. Format withair format(or via the air LSP). - Rust MSRV is declared in
DESCRIPTIONSystemRequirements(currentlyrustc >= 1.81.0);tools/msrv.Renforces it at configure time.