Skip to content

Commit 54f67c0

Browse files
committed
feat: import standalone scripts for ggplot and strict list
1 parent 8c3150a commit 54f67c0

11 files changed

Lines changed: 126 additions & 52 deletions

DESCRIPTION

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ Description: What the package does (one paragraph).
77
License: MIT + file LICENSE
88
Suggests:
99
data.table,
10-
dplyr,
1110
flir,
1211
gh,
1312
pedant,
14-
purrr,
1513
rmarkdown,
16-
testthat (>= 3.0.0),
17-
tibble
14+
testthat (>= 3.0.0)
1815
Config/testthat/edition: 3
1916
Encoding: UTF-8
2017
Roxygen: list(markdown = TRUE)
2118
RoxygenNote: 7.3.3
2219
Imports:
2320
cli,
24-
rlang (>= 1.0.0),
25-
rstudioapi
21+
dplyr,
22+
ggplot2,
23+
knitr,
24+
purrr,
25+
ragg,
26+
rlang,
27+
rstudioapi,
28+
scales,
29+
stats,
30+
stringr,
31+
systemfonts,
32+
tibble
2633
Remotes:
2734
github::wurli/pedant

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method("$",strict_list)
4+
S3method("[",strict_list)
5+
S3method("[[",strict_list)
6+
S3method(as.list,strict_list)
37
export(air_format)
48
export(create_standalone)
59
export(flir_fix)

R/12_render_rmd.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ render_rmd <- function(path = NULL, output_format = "md_document", ...) {
1212
rlang::check_installed("rmarkdown")
1313
path <- if (is.null(path) && rlang::is_installed("rstudioapi")) {
1414
rstudioapi::getActiveDocumentContext()$path
15-
} else {
15+
}
16+
if (is.null(path)) {
1617
cli::cli_abort(("c" = "{.arg path} is required"))
1718
}
1819
rmarkdown::render(input = path, output_format = output_format)

R/13_make_func_call_explicit.R

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
#' Make function calls explicit by adding double colons
1+
#' Make Function Calls Explicit
22
#'
33
#' @description
4-
#' This function reads an R file and adds explicit package namespace qualifiers
5-
#' (double colons) to function calls using the `pedant` package. If no path is
6-
#' provided, it attempts to use the currently active file in RStudio.
4+
#' Add double colons (`::`) to function calls from specified packages to make
5+
#' package dependencies explicit in R code.
76
#'
8-
#' @param path A character string specifying the path to the R file to process.
9-
#' If `NULL` and RStudio is available, the active document path is used.
10-
#' @param ... Additional arguments (currently unused).
7+
#' @param path A character string specifying the path to the R file to modify.
8+
#' If `NULL` and RStudio is available, the currently active document path is used.
9+
#' @param use_packages A character vector of package names to process. Defaults to
10+
#' `pedant::current_packages()`.
11+
#' @param ignore_functions A character vector of function names to ignore. Defaults to
12+
#' `pedant::imported_functions()`.
13+
#' @param ... Additional arguments. Currently unused and must be empty.
1114
#'
12-
#' @return Invisible `NULL`. The function modifies the file in place.
15+
#' @return
16+
#' Invisible `NULL`. This function is called for its side effect of modifying the
17+
#' specified file in place.
1318
#'
1419
#' @details
15-
#' The function requires the `pedant` package to be installed. It reads the file,
16-
#' adds double colons to function calls to make package dependencies explicit,
17-
#' and writes the modified code back to the same file.
20+
#' This function reads the specified R file, identifies function calls from the
21+
#' specified packages, and adds explicit namespace qualifiers (`::`) to those
22+
#' calls. The modified code is written back to the original file.
23+
#'
24+
#' @seealso
25+
#' [pedant::add_double_colons()], [pedant::current_packages()], [pedant::imported_functions()]
1826
#'
1927
#' @examples
2028
#' \dontrun{
2129
#' make_func_call_explicit("path/to/file.R")
22-
#' make_func_call_explicit() # Uses active RStudio file
30+
#' make_func_call_explicit(
31+
#' path = "path/to/file.R",
32+
#' use_packages = c("dplyr", "tidyr"),
33+
#' ignore_functions = c("library", "require")
34+
#' )
2335
#' }
2436
#'
2537
#' @export

R/import-standalone-extra-checks.R

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ check_list <- function(x,
3737
allow_na = FALSE,
3838
allow_empty = FALSE,
3939
allow_null = FALSE,
40-
arg = caller_arg(x),
41-
call = caller_env()) {
40+
arg = rlang::caller_arg(x),
41+
call = rlang::caller_env()) {
4242
if (allow_na && is.na(x)) {
4343
return(invisible(NULL))
4444
}
4545

46-
if (allow_null && is_null(x)) {
46+
if (allow_null && purrr::is_null(x)) {
4747
return(invisible(NULL))
4848
}
4949

50-
if (is_empty(x)) {
50+
if (purrr::is_empty(x)) {
5151
if (allow_empty) {
5252
return(invisible(NULL))
5353
}
5454

55-
cli_abort(
55+
cli::cli_abort(
5656
"{.arg {arg}} can't be empty.",
5757
call = call
5858
)
5959
}
6060

61-
if (is_list(x)) {
61+
if (rlang::is_list(x)) {
6262
return(invisible(NULL))
6363
}
6464

@@ -73,7 +73,7 @@ check_list <- function(x,
7373
#' Does x match the pattern of a URL?
7474
#' @noRd
7575
is_url <- function(x, pattern = NULL, ...) {
76-
if (!is_vector(x) || is_empty(x)) {
76+
if (!rlang::is_vector(x) || rlang::is_empty(x)) {
7777
return(FALSE)
7878
}
7979

@@ -91,9 +91,9 @@ check_url <- function(url,
9191
pattern = NULL,
9292
...,
9393
allow_null = FALSE,
94-
arg = caller_arg(url),
95-
call = caller_env()) {
96-
if (allow_null && is_null(url)) {
94+
arg = rlang::caller_arg(url),
95+
call = rlang::caller_env()) {
96+
if (allow_null && purrr::is_null(url)) {
9797
return(invisible(NULL))
9898
}
9999

@@ -177,26 +177,26 @@ check_exclusive_args <- function(x = NULL,
177177
y = NULL,
178178
require = TRUE,
179179
...,
180-
x_arg = caller_arg(x),
181-
y_arg = caller_arg(y),
182-
call = caller_env()) {
183-
if (is_empty(c(x, y))) {
180+
x_arg = rlang::caller_arg(x),
181+
y_arg = rlang::caller_arg(y),
182+
call = rlang::caller_env()) {
183+
if (purrr::is_empty(c(x, y))) {
184184
if (!require) {
185185
return(invisible(NULL))
186186
}
187187

188-
cli_abort(
188+
cli::cli_abort(
189189
"One of {.arg {x_arg}} or {.arg {y_arg}} must be supplied.",
190190
call = call,
191191
...
192192
)
193193
}
194194

195-
if (!has_length(c(x, y), 2)) {
195+
if (!rlang::has_length(c(x, y), 2)) {
196196
return(invisible(NULL))
197197
}
198198

199-
cli_abort(
199+
cli::cli_abort(
200200
"Exactly one of {.arg {x_arg}} or {.arg {y_arg}} must be supplied.",
201201
call = call,
202202
...
@@ -236,13 +236,13 @@ check_has_name <- function(x,
236236
add_msg <- NULL
237237
}
238238

239-
cli_abort(
239+
cli::cli_abort(
240240
message = c(
241241
"{.arg {arg}} must have{what} the name{cli::qty(n)}{?s} {.val {nm}}.",
242242
add_msg
243243
),
244244
...,
245-
.envir = current_env(),
245+
.envir = rlang::current_env(),
246246
call = call
247247
)
248248
}

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Codecov test coverage](https://codecov.io/gh/Exceret/rpkgkit/graph/badge.svg)](https://app.codecov.io/gh/Exceret/rpkgkit)
1111
<!-- badges: end -->
1212

13-
The goal of rpkgkit is to collect useful functions and standalone scripts for R package development.
13+
The goal of rpkgkit is to collect useful functions and standalone scripts for R package development. use `usethis::use_standalone()` to import the standalone scripts.
1414

1515
## Installation
1616

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ status](https://www.r-pkg.org/badges/version/rpkgkit)](https://CRAN.R-project.or
1313
coverage](https://codecov.io/gh/Exceret/rpkgkit/graph/badge.svg)](https://app.codecov.io/gh/Exceret/rpkgkit)
1414
<!-- badges: end -->
1515

16-
The goal of rpkgkit is to …
16+
The goal of rpkgkit is to collect useful functions and standalone
17+
scripts for R package development. use `usethis::use_standalone()` to
18+
import the standalone scripts.
1719

1820
## Installation
1921

man/as_strict_list.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/inquire_standalone.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/make_func_call_explicit.Rd

Lines changed: 25 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)