diff --git a/DESCRIPTION b/DESCRIPTION index e017f971..f25c1e61 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,9 +38,8 @@ Suggests: testthat, yaml, texPreview, magick, pdftools, withr Encoding: UTF-8 Language: en-US LazyData: true -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) -VignetteBuilder: knitr Collate: 'class-new_names.R' 'class-digits.R' diff --git a/R/AAAA.R b/R/AAAA.R index a0ddf335..38ce1d00 100644 --- a/R/AAAA.R +++ b/R/AAAA.R @@ -198,10 +198,8 @@ find_cached_root <- function() { # #' #' @md -#' @docType package #' @name pmtables -NULL - +"_PACKAGE" #' Load an example data set #' diff --git a/R/preview-standalone.R b/R/preview-standalone.R index 7888d0e4..c5e26948 100644 --- a/R/preview-standalone.R +++ b/R/preview-standalone.R @@ -98,15 +98,14 @@ st_to_standalone <- function(text, stem, dir, vwidth <- "" } - env <- list( - border = border, - texfile = texfile, - font = fonts[[font]], - textw_tex = as.character(textw_tex), - rule = rule, - vwidth = vwidth, - ltversion = paste0("[=v", ltversion, "]%") - ) + env <- new.env() + env$border <- border + env$texfile <- texfile + env$font <- fonts[[font]] + env$textw_tex <- as.character(textw_tex) + env$rule <- rule + env$vwidth <- vwidth + env$ltversion <- paste0("[=v", ltversion, "]%") temp_text <- mgluet(temp_text, .envir = env) build_file <- basename(temp_file) diff --git a/R/preview.R b/R/preview.R index 7843e410..641ea329 100644 --- a/R/preview.R +++ b/R/preview.R @@ -248,7 +248,7 @@ st2article <- function(..., .list = NULL, ntex = 1, #nocov start temp <- readLines(template) - env <- list() + env <- new.env() env$list_of_tables <- c("\\listoftables", "\\clearpage") env$input_file <- st2article_input env$hmargin <- margin[1] diff --git a/R/table-utils.R b/R/table-utils.R index 331aef83..42f35e77 100644 --- a/R/table-utils.R +++ b/R/table-utils.R @@ -112,6 +112,9 @@ require_col <- function(data,col,context=NULL) { gluet <- function(x, .envir = parent.frame(), ...) { x <- force(x) + if(!is.environment(.envir)) { + abort("pmtables error: cannot `glue()` - .envir is not an environment.") + } glue(x,.open = "<", .close = ">", .envir = .envir) } diff --git a/man/pmtables.Rd b/man/pmtables.Rd index 6efa2d35..f4c9db7a 100644 --- a/man/pmtables.Rd +++ b/man/pmtables.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/AAAA.R \docType{package} \name{pmtables} +\alias{pmtables-package} \alias{pmtables} \title{pmtables: Tables for Pharmacometrics.} \description{ @@ -191,3 +192,24 @@ each individual } } +\seealso{ +Useful links: +\itemize{ + \item \url{https://metrumresearchgroup.github.io/pmtables} + \item \url{https://github.com/metrumresearchgroup/pmtables} + \item Report bugs at \url{https://github.com/metrumresearchgroup/pmtables/issues} +} + +} +\author{ +\strong{Maintainer}: Kyle Baron \email{kyleb@metrumrg.com} + +Other contributors: +\itemize{ + \item Anna-Christina Nevison \email{annan@metrumrg.com} [contributor] + \item Katherine Kay \email{katherinek@metrumrg.com} [contributor] + \item Devin Pastoor \email{devin.pastoor@gmail.com} [contributor] + \item Kyle Barrett \email{barrettk@metrumrg.com} [contributor] +} + +} diff --git a/tests/testthat/test-table-utils.R b/tests/testthat/test-table-utils.R index 2b20c498..7dcd9824 100644 --- a/tests/testthat/test-table-utils.R +++ b/tests/testthat/test-table-utils.R @@ -278,3 +278,12 @@ test_that("table-utils paste units [PMT-TEST-0239]", { c("B mg", "E", "D kg", "C pounds", "A") ) }) + +test_that("error is generated when calling gluet with non-environment", { + x <- list(a = 1, b = 2, c = 3) + what <- "" + expect_error(pmtables:::gluet(what, .envir = x), "pmtables error:") + env <- as.environment(x) + ans <- pmtables:::gluet(what, .envir = env) + expect_identical(unclass(ans), "213") +})