How novonordisk-opensource/zephyr works
Project Type and Purpose
• zephyr is an R package—a developer utility library—designed to be embedded into other R packages.
• Its core responsibility is to provide:
– A unified messaging/verbosity framework (msg_* functions) built on top of {cli}.
– Utilities to create, retrieve, and document package-specific options (create_option, get_option, list_options).
– A boilerplate generator (use_zephyr()) to set up option scaffolding in client packages.
Main Architectural Components
A. Core Library (R/)
– msg.R, checkmate.R, options.R, etc.
– Implements messaging API, option management, default configurations.
B. API Entry Points
– use_zephyr.R: scaffolding function to inject boilerplate into client packages.
– create_option.Rd, get_option.Rd (in man/) – user-facing documentation stubs.
C. Configuration & Defaults (inst/)
– setup-options.R: default option registration script.
– WORDLIST: internal resource for message word lists.
D. Documentation Site (pkgdown/)
– Static assets, favicon, config in _pkgdown.yml.
E. Testing Suite (tests/)
– unit tests (testthat), integration snapshots (_snaps).
– helper scripts under tests/testthat/scripts.
F. Continuous Integration ( .github/workflows )
– check_and_co.yaml: lint, test, coverage, CRAN checks.
G. Build & Package Metadata
– DESCRIPTION, NAMESPACE, LICENSE.md, NEWS.md, cran-comments.md.
Relationships & Data Flows
• Client Package Developer → calls use_zephyr() → Core Library → writes R/{pkg}-options.R + inst/setup-options.R
• Core Library functions (msg_success, etc.) → depend on {cli} and current verbosity option → render messages to console.
• create_option/get_option → interact with package’s options store (registered in .onLoad via inst/setup-options.R).
• pkgdown generates website from man/, vignettes, README.Rmd using _pkgdown.yml.
• tests invoke Core Library functions and options to validate behavior.
• CI triggers tests, coverage, linting whenever code is pushed.
Architectural Patterns & Principles
– Modular layering:
• Core API layer (msg_*, create_option, get_option).
• Infrastructure layer (on-load option registration, cli rendering).
• Scaffolding/code generation (use_zephyr).
– Convention-over-configuration: sensible defaults, centralized option store.
– Separation of concerns: messaging vs. option management vs. scaffolding vs. docs vs. testing.