Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: docorator
Title: Docorate (Decorate + Output) Displays
Version: 0.7.0
Version: 0.7.0.9000
Authors@R:
c(
person(given = "Shannon", family = "Haughton", email = "shannon.l.haughton@gsk.com", role = c("aut", "cre")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# docorator (development version)
Improvements
* Check that display objects are not empty before processing with as_docorator (#125)

# docorator 0.7.0
Improvements
* Added Word (.docx) output support with the new render_docx() engine. (#97)
Expand Down
1 change: 1 addition & 0 deletions R/docorate.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ as_docorator <- function(
# check inputs
check_fancyhdr(header, chr_ok = TRUE)
check_fancyhdr(footer)
check_display(x)

# prep displays for render
x <- prep_display(
Expand Down
13 changes: 13 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,17 @@ prep_display <- function(x, fig_dim = c(5,8), convert_ggplot = TRUE, fontsize =
)

x
}

#' Check that the display object is not empty
#' @param x object passed to `as_docorator`
#' @noRd
#'
check_display <- function(x) {
if(rlang::is_empty(x))) {
Comment thread
shannonhaughton marked this conversation as resolved.
Outdated
cli::cli_abort(
"The {.arg {rlang::caller_arg(x)}} argument cannot be empty or NULL. Please provide a valid display object.",
call = rlang::caller_env()
)
}
}
18 changes: 18 additions & 0 deletions tests/testthat/test_docorate.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,21 @@ test_that("Create docorator object without display_name errors",{


})

test_that("Create docorator object with invalid display errors",{

expect_error(as_docorator(
x = list(),
display_name = "empty_list",
save_object = FALSE
),
"The `x` argument cannot be empty or NULL. Please provide a valid display object.")

expect_error(as_docorator(
x = NULL,
display_name = "null_object",
save_object = FALSE
),
"The `x` argument cannot be empty or NULL. Please provide a valid display object.")

})
Loading