| Title: | Development tooling for the bixverse family of R packages |
|---|---|
| Description: | Dev-time tooling, not a runtime dependency. Generates the parameter wrapper constructors and their paired checkmate extensions from a declarative spec, and lints the things the house style asks for but cannot enforce: roxygen that has drifted away from the formals it documents, function inputs that never reach a checkmate assertion, and rextendr bindings without an R wrapper. |
| Authors: | Gregor Lueg [aut, cre] |
| Maintainer: | Gregor Lueg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.7 |
| Built: | 2026-10-07 06:02:40 UTC |
| Source: | https://github.com/GregorLueg/devforge |
Reads every spec under inst/params/, writes the three
generated files under R/ and formats them with air. The generated files
are meant to be committed.
forge_params(pkg = ".", .verbose = TRUE)forge_params(pkg = ".", .verbose = TRUE)
pkg |
String. Path to the package root. Defaults to |
.verbose |
Boolean. Report what was written. Defaults to |
Character vector of the paths written, invisibly.
Sources every .R file under inst/params/ in a fresh
environment and returns the devforge_spec objects it finds, in file then
definition order.
load_specs(pkg = ".")load_specs(pkg = ".")
pkg |
String. Path to the package root. Defaults to |
A named list of devforge_spec objects, named by their name.
Emits match.arg() plus checkmate::assertChoice() in the
constructor and a apply_choice_rules() entry in the checker, which is what
the packages already do by hand. default is moved to the front of
choices so the generated formal reads method = c("default", ...).
p_choice(default, choices, doc = NULL)p_choice(default, choices, doc = NULL)
default |
String. The default value. Must be one of |
choices |
Character vector. The allowed values. |
doc |
String or |
A devforge_field.
String field
p_chr(default, null_ok = FALSE, len = 1L, doc = NULL)p_chr(default, null_ok = FALSE, len = 1L, doc = NULL)
default |
String or |
null_ok |
Boolean. Whether |
len |
Integer or string. |
doc |
String or |
A devforge_field.
Numeric field
p_dbl( default, range = NULL, null_ok = FALSE, len = 1L, strict = FALSE, doc = NULL )p_dbl( default, range = NULL, null_ok = FALSE, len = 1L, strict = FALSE, doc = NULL )
default |
Numeric or |
range |
String or |
null_ok |
Boolean. Whether |
len |
Integer or string. |
strict |
Boolean. |
doc |
String or |
A devforge_field.
For anything a qassert pattern cannot express. The field
contributes a formal, a default and its roxygen, but no assertion and no
rule table entry. Pair it with extra_ctor / extra_check on the spec.
p_free(default, doc = NULL)p_free(default, doc = NULL)
default |
Any. The default value. Leave it out for a formal the caller must supply. |
doc |
String or |
A devforge_field.
Integer field
p_int( default, range = NULL, null_ok = FALSE, len = 1L, integerish = FALSE, check_as = NULL, doc = NULL )p_int( default, range = NULL, null_ok = FALSE, len = 1L, integerish = FALSE, check_as = NULL, doc = NULL )
default |
Integer or |
range |
String or |
null_ok |
Boolean. Whether |
len |
Integer or string. |
integerish |
Boolean. Accept whole doubles such as |
check_as |
Character vector or |
doc |
String or |
A devforge_field.
Boolean field
p_lgl(default, null_ok = FALSE, doc = NULL)p_lgl(default, null_ok = FALSE, doc = NULL)
default |
Boolean or |
null_ok |
Boolean. Whether |
doc |
String or |
A devforge_field.
For the constructors that take a list of overrides for a
shared defaults block, e.g. knn = list(k = 25L) on top of
params_knn_defaults(). The constructor merges the caller's list into the
base with modifyList(keep.null = TRUE) and splices the result flat into
the returned list at this field's position. When from names another spec,
the checker requires the spliced elements and validates them with that
spec's rules.
p_merge( from, default = list(), overrides = NULL, drop = NULL, strict = FALSE, doc = NULL )p_merge( from, default = list(), overrides = NULL, drop = NULL, strict = FALSE, doc = NULL )
from |
String or language object. The name of a spec in the same
package ( |
default |
List or language object. The formal default. Defaults to
|
overrides |
List, language object or |
drop |
Character vector or |
strict |
Boolean. The constructor rejects caller elements that are not
in the base (after |
doc |
String or |
A devforge_field.
A zero-argument params_*_defaults() helper. Same fields as a
param_spec(), but the generated function takes no arguments, runs no
assertions and simply returns the defaults. These exist to be embedded in
other constructors.
param_defaults( name, title, fields, description = NULL, details = NULL, references = NULL, checker = NULL, label = NULL, hint = NULL, export = TRUE )param_defaults( name, title, fields, description = NULL, details = NULL, references = NULL, checker = NULL, label = NULL, hint = NULL, export = TRUE )
name |
String. Snake case stem. |
title |
String. The roxygen title line. |
fields |
Named list of |
description |
String or |
details |
String or |
references |
String or |
checker |
String or |
label |
String or |
hint |
String or |
export |
Boolean. Whether the helper gets |
A list of class devforge_spec.
The declarative description of one params_*() constructor and
its paired checkmate extension. Everything the generator emits comes from
here.
param_spec( name, title, fields, description = NULL, details = NULL, references = NULL, return_order = NULL, checker = to_pascal_case(name), checker_args = list(), extra_ctor = NULL, extra_check = NULL, class_tag = NULL, strict_names = FALSE, label = NULL, hint = NULL, test_fn = FALSE, export = TRUE )param_spec( name, title, fields, description = NULL, details = NULL, references = NULL, return_order = NULL, checker = to_pascal_case(name), checker_args = list(), extra_ctor = NULL, extra_check = NULL, class_tag = NULL, strict_names = FALSE, label = NULL, hint = NULL, test_fn = FALSE, export = TRUE )
name |
String. Snake case stem. |
title |
String. The roxygen title line for the constructor. |
fields |
Named list of |
description |
String or |
details |
String or |
references |
String or |
return_order |
Character vector or |
checker |
String or |
checker_args |
A list made with |
extra_ctor |
Language object or |
extra_check |
Language object or |
class_tag |
String or |
strict_names |
Boolean. |
label |
String or |
hint |
String or |
test_fn |
Boolean. Also emit |
export |
Boolean. Whether the constructor gets |
A list of class devforge_spec.
Regenerates into a temporary directory and compares. Meant for CI, so that a hand-edit of a generated file or a spec change that was never regenerated fails the build.
params_up_to_date(pkg = ".")params_up_to_date(pkg = ".")
pkg |
String. Path to the package root. Defaults to |
TRUE when everything matches, otherwise a character vector of the
paths that are out of date.
Copies a GitHub Actions workflow into
.github/workflows/params-drift.yml that installs devforge and fails the
build when params_up_to_date() reports stale generated files. Also adds
^\.github$ to .Rbuildignore if it is not there yet.
use_drift_ci( pkg = ".", runner = "macos-latest", overwrite = FALSE, .verbose = TRUE )use_drift_ci( pkg = ".", runner = "macos-latest", overwrite = FALSE, .verbose = TRUE )
pkg |
String. Path to the package root. Defaults to |
runner |
String. The GitHub Actions runner. Has to match the platform
the specs are forged on: macOS arm64 R has no extended long double, so
literals like |
overwrite |
Boolean. Replace an existing workflow file. Defaults to
|
.verbose |
Boolean. Report what was written. Defaults to |
The path of the workflow file, invisibly.