Enhances: Functions That Enhance the Use of Other Packages

EnhancesR Documentation

Functions That Enhance the Use of Other Packages

Description

These functions improve the user experience of other packages.

Usage

## enchances 'package:box'
with_script_path(expr, local = FALSE, n = 0, envir = parent.frame(n + 1),
    matchThisEnv = getOption("topLevelEnvironment"),
    srcfile = if (n) sys.parent(n) else 0)

## enchances 'package:rprojroot'
make_fix_file(criterion, local = FALSE, n = 0, envir = parent.frame(n + 1),
    matchThisEnv = getOption("topLevelEnvironment"),
    srcfile = if (n) sys.parent(n) else 0)

Arguments

expr

an expression to evaluate after setting the current script in package:box; most commonly a call to \codelink3box:usebox::use().

criterion

argument passed to \codelink3rprojroot:find_rootrprojroot::find_root().

local, n, envir, matchThisEnv, srcfile

See ?this.path().

Details

with_script_path() improves the experience of \CRANpackagebox; it sets the current script in package:box to this.path() using \codelink3box:script_pathbox::set_script_path(), then evaluates its argument, most commonly a package:box import statement.

make_fix_file() improves the experience of \CRANpackagerprojroot; it looks for a project root starting with this.dir(), then makes a function that constructs file paths against said project root.

Value

for with_script_path(), the result of evaluating expr.

for make_fix_file(), a function with formals (..., .. = 0) that returns a character vector.

Examples

# @R_PACKAGE_NAME@::with_script_path(
# box::use(
#     <import 1>,
#     <import 2>,
#     <...>
# )
# )


# ## replace 'rprojroot::is_r_package' with desired criterion
#
# fix_file <- @R_PACKAGE_NAME@::make_fix_file(rprojroot::is_r_package)

ArcadeAntics/this.path documentation built on July 31, 2024, 12:25 p.m.