From f06da3164c7b5d6ce63a4359aae640da7f0c760c Mon Sep 17 00:00:00 2001 From: Shannon Haughton <106977606+shannonhaughton@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:00:10 +0100 Subject: [PATCH 1/6] Upversion news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index e66c327..a51df9d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# docorator (development version) + # docorator 0.7.0 Improvements * Added Word (.docx) output support with the new render_docx() engine. (#97) From 4ee8857b02a683eb531c31d1b4836855e9fb9bb2 Mon Sep 17 00:00:00 2001 From: Shannon Haughton <106977606+shannonhaughton@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:01:02 +0100 Subject: [PATCH 2/6] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f2f8f5..296f303 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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")), From ed1c27a97e4ade91aef3bd3309e335263e502b40 Mon Sep 17 00:00:00 2001 From: Shannon Haughton Date: Mon, 13 Jul 2026 16:38:24 +0100 Subject: [PATCH 3/6] dont allow null displays --- R/docorate.R | 1 + R/utils.R | 13 +++++++++++++ tests/testthat/test_docorate.R | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/R/docorate.R b/R/docorate.R index 2cdd345..ba1b8b6 100644 --- a/R/docorate.R +++ b/R/docorate.R @@ -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( diff --git a/R/utils.R b/R/utils.R index 6c9441c..b20ef99 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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(is.null(x) || (identical(class(x), "list") && length(x) == 0)) { + 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() + ) + } } \ No newline at end of file diff --git a/tests/testthat/test_docorate.R b/tests/testthat/test_docorate.R index 4696f5c..c586899 100644 --- a/tests/testthat/test_docorate.R +++ b/tests/testthat/test_docorate.R @@ -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.") + +}) From 36c7e7f67629255806ef04079c6e411aa792458e Mon Sep 17 00:00:00 2001 From: Shannon Haughton Date: Mon, 13 Jul 2026 16:39:34 +0100 Subject: [PATCH 4/6] news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index a51df9d..0513344 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,6 @@ # docorator (development version) +Improvements +* Check that display objects are not empty before processing with as_docorator (#125) # docorator 0.7.0 Improvements From 2008d5486eb4ea8e5008fe53b7e18f5dd4e9058b Mon Sep 17 00:00:00 2001 From: Shannon Haughton <106977606+shannonhaughton@users.noreply.github.com> Date: Tue, 14 Jul 2026 15:19:24 +0100 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Shannon Haughton <106977606+shannonhaughton@users.noreply.github.com> --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index b20ef99..57698df 100644 --- a/R/utils.R +++ b/R/utils.R @@ -353,7 +353,7 @@ prep_display <- function(x, fig_dim = c(5,8), convert_ggplot = TRUE, fontsize = #' @noRd #' check_display <- function(x) { - if(is.null(x) || (identical(class(x), "list") && length(x) == 0)) { + if(rlang::is_empty(x))) { 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() From cad03774059e05640812397a0c8124231dcff992 Mon Sep 17 00:00:00 2001 From: Shannon Haughton <106977606+shannonhaughton@users.noreply.github.com> Date: Tue, 14 Jul 2026 15:52:21 +0100 Subject: [PATCH 6/6] Apply suggestion from @shannonhaughton --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 57698df..3abd94a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -353,7 +353,7 @@ prep_display <- function(x, fig_dim = c(5,8), convert_ggplot = TRUE, fontsize = #' @noRd #' check_display <- function(x) { - if(rlang::is_empty(x))) { + if(rlang::is_empty(x)) { 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()