Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

208 CRAN requirements for the first submission [skip vbump] #209

Merged
merged 17 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
LICENSE
dev/internal_examples.R
^.*\.Rproj$
^Jenkinsfile$
^Makefile$
Expand Down
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: teal.reporter
Title: Reporting Tools for Shiny Modules
Version: 0.2.0.9003
Title: Reporting Tools for 'shiny' Modules
Version: 0.2.1
Date: 2023-09-05
Authors@R: c(
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = "cre"),
Expand All @@ -9,9 +9,10 @@ Authors@R: c(
person(c("Mahmoud", "mahmoud.hallal@roche.com"), "Hallal", role = "aut"),
person("F. Hoffmann-La Roche AG", role = c("cph", "fnd"))
)
Description: Reporting tools for your shiny modules to generate
reproducible analysis.
License: Apache License 2.0 | file LICENSE
Description:
Prebuilt 'shiny' modules containing tools for the generation of 'rmarkdown' reports, supporting reproducible
research and analysis.
License: Apache License 2.0
URL: https://github.com/insightsengineering/teal.reporter,
https://insightsengineering.github.io/teal.reporter/
BugReports: https://github.com/insightsengineering/teal.reporter/issues
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# teal.reporter 0.2.0.9003
# teal.reporter 0.2.1

### Miscellaneous

* Specify minimal version of dependent packages.
* Fixed CRAN requirements for the first CRAN submission.
* Removed manual pages for non-exported objects.

# teal.reporter 0.2.0

Expand Down
45 changes: 2 additions & 43 deletions R/Archiver.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Archiver <- R6::R6Class( # nolint: object_name_linter.
#' @description Returns an `Archiver` object.
#'
#' @return an `Archiver` object
#' @examples
#' archiver <- teal.reporter:::Archiver$new()
#'
initialize = function() {
invisible(self)
},
Expand Down Expand Up @@ -39,9 +36,6 @@ FileArchiver <- R6::R6Class( # nolint: object_name_linter.
#' @description Returns a `FileArchiver` object.
#'
#' @return a `FileArchiver` object
#' @examples
#' archiver <- teal.reporter:::FileArchiver$new()
#'
initialize = function() {
tmp_dir <- tempdir()
output_dir <- file.path(tmp_dir, sprintf("archive_%s", gsub("[.]", "", format(Sys.time(), "%Y%m%d%H%M%OS4"))))
Expand All @@ -56,9 +50,6 @@ FileArchiver <- R6::R6Class( # nolint: object_name_linter.
#' @description get `output_dir` field
#'
#' @return `character` a `output_dir` field path.
#' @examples
#' archiver <- teal.reporter:::FileArchiver$new()
#' archiver$get_output_dir()
get_output_dir = function() {
private$output_dir
}
Expand All @@ -77,22 +68,8 @@ JSONArchiver <- R6::R6Class( # nolint: object_name_linter.
#' @description write a `Reporter` instance in to this `JSONArchiver` object.
#'
#' @param reporter `Reporter` instance.
#' @return invisibly self
#' @examples
#' card1 <- teal.reporter:::ReportCard$new()
#'
#' card1$append_text("Header 2 text", "header2")
#' card1$append_text("A paragraph of default text", "header2")
#' card1$append_plot(
#' ggplot2::ggplot(iris, ggplot2::aes(x = Petal.Length)) + ggplot2::geom_histogram()
#' )
#'
#' reporter <- teal.reporter:::Reporter$new()
#' reporter$append_cards(list(card1))
#'
#' archiver <- teal.reporter:::JSONArchiver$new()
#' archiver$write(reporter)
#' archiver$get_output_dir()
#' @return invisibly self
write = function(reporter) {
checkmate::assert_class(reporter, "Reporter")
unlink(list.files(private$output_dir, recursive = TRUE, full.names = TRUE))
Expand All @@ -102,26 +79,8 @@ JSONArchiver <- R6::R6Class( # nolint: object_name_linter.
#' @description read a `Reporter` instance from a directory with `JSONArchiver`.
#'
#' @param path `character(1)` a path to the directory with all proper files.
#' @return `Reporter` instance.
#' @examples
#' card1 <- teal.reporter:::ReportCard$new()
#'
#' card1$append_text("Header 2 text", "header2")
#' card1$append_text("A paragraph of default text", "header2")
#' card1$append_plot(
#' ggplot2::ggplot(iris, ggplot2::aes(x = Petal.Length)) + ggplot2::geom_histogram()
#' )
#'
#' reporter <- teal.reporter:::Reporter$new()
#' reporter$append_cards(list(card1))
#'
#' archiver <- teal.reporter:::JSONArchiver$new()
#' archiver$write(reporter)
#' archiver$get_output_dir()
#'
#' archiver$read()$get_cards()[[1]]$get_content()
#' blocks <- teal.reporter:::Reporter$new()$from_reporter(archiver$read())$get_blocks()
#' doc <- teal.reporter:::Renderer$new()$render(blocks)
#' @return `Reporter` instance.
read = function(path = NULL) {
checkmate::assert(
checkmate::check_null(path),
Expand Down
17 changes: 4 additions & 13 deletions R/ContentBlock.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@ ContentBlock <- R6::R6Class( # nolint: object_name_linter.
#' @details Returns a `ContentBlock` object with no content and the default style.
#'
#' @return `ContentBlock`
#' @examples
#' block <- teal.reporter:::ContentBlock$new()
#'
initialize = function() {
private$content <- character(0)
invisible(self)
},
#' @description Sets content of this `ContentBlock`.
#'
#' @param content (`character(0)` or `character(1)`) a string literal or a file path assigned to this `ContentBlock`
#' @return invisibly self
#' @examples
#' block <- teal.reporter:::ContentBlock$new()
#' block$set_content("Base64 encoded picture")
#'
#' @return invisibly self
set_content = function(content) {
checkmate::assert_character(content, min.len = 0, max.len = 1)
private$content <- content
Expand All @@ -31,36 +25,33 @@ ContentBlock <- R6::R6Class( # nolint: object_name_linter.
#' @description Returns the absolute path to content of this `ContentBlock`
#'
#' @return `character` content of this `ContentBlock`
#' @examples
#' block <- teal.reporter:::ContentBlock$new()
#' block$get_content()
#'
get_content = function() {
private$content
},
#' @description Create the `ContentBlock` from a list.
#'
#' @param x `named list` with two fields `c("text", "style")`.
#' Use the `get_available_styles` method to get all possible styles.
#'
#' @return invisibly self
from_list = function(x) {
invisible(self)
},
#' @description Convert the `ContentBlock` to a list.
#'
#' @return `named list` with a text and style.
to_list = function() {
list()
}
),
private = list(
content = character(0),

# @description The copy constructor.
#
# @param name `character(1)` the name of the field
# @param value the value assigned to the field
#
# @return the value of the copied field
#
deep_clone = function(name, value) {
if (name == "content" && checkmate::test_file_exists(value)) {
extension <- ""
Expand Down
14 changes: 4 additions & 10 deletions R/FileBlock.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
#' @title `FileBlock`
#' @keywords internal
#'
FileBlock <- R6::R6Class( # nolint: object_name_linter.
classname = "FileBlock",
inherit = ContentBlock,
public = list(
#' @description finalize of this `FileBlock`.
#'
#' @details Removes the temporary file created in the constructor.
#'
finalize = function() {
try(unlink(super$get_content()))
},
#' @description Create the `FileBlock` from a list.
#' The list should contain one named field, `"basename"`.
#'
#' @param x `named list` with one field `"basename"`, a name of the file.
#' @param output_dir `character` with a path to the directory where a file will be copied.
#'
#' @return invisibly self
#' @examples
#' block <- teal.reporter:::FileBlock$new()
#' file_path <- tempfile(fileext = ".png")
#' saveRDS(iris, file_path)
#' block$from_list(list(basename = basename(file_path)), dirname(file_path))
from_list = function(x, output_dir) {
checkmate::assert_list(x)
checkmate::assert_names(names(x), must.include = "basename")
Expand All @@ -34,11 +29,10 @@ FileBlock <- R6::R6Class( # nolint: object_name_linter.
invisible(self)
},
#' @description Convert the `FileBlock` to a list.
#'
#' @param output_dir `character` with a path to the directory where a file will be copied.
#'
#' @return `named list` with a `basename` of the file.
#' @examples
#' block <- teal.reporter:::FileBlock$new()
#' block$to_list(tempdir())
to_list = function(output_dir) {
base_name <- basename(super$get_content())
file.copy(super$get_content(), file.path(output_dir, base_name))
Expand Down
4 changes: 0 additions & 4 deletions R/NewpageBlock.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#' @title `NewpageBlock`
#' @keywords internal
#'
NewpageBlock <- R6::R6Class( # nolint: object_name_linter.
classname = "NewpageBlock",
inherit = ContentBlock,
Expand All @@ -10,9 +9,6 @@ NewpageBlock <- R6::R6Class( # nolint: object_name_linter.
#' @details Returns a `NewpageBlock` object with no content and the default style.
#'
#' @return `NewpageBlock`
#' @examples
#' block <- teal.reporter:::NewpageBlock$new()
#'
initialize = function() {
super$set_content("\n\\newpage\n")
invisible(self)
Expand Down
32 changes: 5 additions & 27 deletions R/PictureBlock.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' @title `PictureBlock`
#' @keywords internal
#'
#' @noRd
PictureBlock <- R6::R6Class( # nolint: object_name_linter.
classname = "PictureBlock",
inherit = FileBlock,
public = list(
#' @description Returns a new `PictureBlock` object.
#'
#' @param plot (`ggplot`, `grid`) a picture in this `PictureBlock`
#' @return a `PictureBlock` object
#'
#' @return a `PictureBlock` object
initialize = function(plot) {
if (!missing(plot)) {
self$set_content(plot)
Expand All @@ -21,16 +21,8 @@ PictureBlock <- R6::R6Class( # nolint: object_name_linter.
#' @details throws if argument is not a `ggplot`, `grob` or `trellis` plot.
#'
#' @param content (`ggplot`, `grob`, `trellis`) a picture in this `PictureBlock`
#' @return invisibly self
#' @examples
#' block <- teal.reporter:::PictureBlock$new()
#' block$set_content(ggplot2::ggplot(iris))
#'
#' block <- teal.reporter:::PictureBlock$new()
#' block$set_content(lattice::bwplot(1))
#'
#' block <- teal.reporter:::PictureBlock$new()
#' block$set_content(ggplot2::ggplotGrob(ggplot2::ggplot(iris)))
#' @return invisibly self
set_content = function(content) {
checkmate::assert_multi_class(content, private$supported_plots)
path <- tempfile(fileext = ".png")
Expand All @@ -57,11 +49,8 @@ PictureBlock <- R6::R6Class( # nolint: object_name_linter.
#' @details throws if argument is not `character(1)`.
#'
#' @param title (`character(1)`) a string assigned to this `PictureBlock`
#' @return invisibly self
#' @examples
#' block <- teal.reporter:::PictureBlock$new()
#' block$set_title("Title")
#'
#' @return invisibly self
set_title = function(title) {
checkmate::assert_string(title)
private$title <- title
Expand All @@ -70,21 +59,14 @@ PictureBlock <- R6::R6Class( # nolint: object_name_linter.
#' @description Returns the title of this `PictureBlock`
#'
#' @return the content of this `PictureBlock`
#' @examples
#' block <- teal.reporter:::PictureBlock$new()
#' block$get_title()
#'
get_title = function() {
private$title
},
#' @description Sets the dimensions of this `PictureBlock`
#'
#' @param dim `numeric` figure dimensions (width and height) in pixels, length 2.
#' @return `self`
#' @examples
#' block <- teal.reporter:::PictureBlock$new()
#' block$set_dim(c(800, 600))
#'
#' @return `self`
set_dim = function(dim) {
checkmate::assert_numeric(dim, len = 2)
private$dim <- dim
Expand All @@ -93,10 +75,6 @@ PictureBlock <- R6::R6Class( # nolint: object_name_linter.
#' @description Returns the dimensions of this `PictureBlock`
#'
#' @return `numeric` the array of 2 numeric values representing width and height in pixels.
#' @examples
#' block <- teal.reporter:::PictureBlock$new()
#' block$get_dim()
#'
get_dim = function() {
private$dim
}
Expand Down
25 changes: 4 additions & 21 deletions R/RcodeBlock.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ RcodeBlock <- R6::R6Class( # nolint: object_name_linter.
#' @param ... any `rmarkdown` R chunk parameter and it value.
#'
#' @return `RcodeBlock`
#' @examples
#' block <- teal.reporter:::RcodeBlock$new()
#'
initialize = function(content = character(0), ...) {
super$set_content(content)
self$set_params(list(...))
Expand All @@ -25,11 +22,8 @@ RcodeBlock <- R6::R6Class( # nolint: object_name_linter.
#' @details The parameters has bearing on the rendering of this block.
#'
#' @param params (`list`) any `rmarkdown` R chunk parameter and its value.
#' @return invisibly self
#' @examples
#' block <- teal.reporter:::RcodeBlock$new()
#' block$set_params(list(echo = TRUE))
#'
#' @return invisibly self
set_params = function(params) {
checkmate::assert_list(params, names = "named")
checkmate::assert_subset(names(params), self$get_available_params())
Expand All @@ -39,30 +33,21 @@ RcodeBlock <- R6::R6Class( # nolint: object_name_linter.
#' @description Returns the parameters of this `RcodeBlock`.
#'
#' @return `character` the parameters of this `RcodeBlock`
#' @examples
#' block <- teal.reporter:::RcodeBlock$new()
#' block$get_params()
#'
get_params = function() {
private$params
},
#' @description Returns an array of parameters available to this `RcodeBlock`.
#'
#' @return a `character` array of parameters
#' @examples
#' block <- teal.reporter:::RcodeBlock$new()
#' block$get_available_params()
#'
get_available_params = function() {
names(knitr::opts_chunk$get())
},
#' @description Create the `RcodeBlock` from a list.
#'
#' @param x `named list` with two fields `c("text", "params")`.
#' Use the `get_available_params` method to get all possible parameters.
#'
#' @return invisibly self
#' @examples
#' block <- teal.reporter:::RcodeBlock$new()
#' block$from_list(list(text = "sth", params = list()))
from_list = function(x) {
checkmate::assert_list(x)
checkmate::assert_names(names(x), must.include = c("text", "params"))
Expand All @@ -71,10 +56,8 @@ RcodeBlock <- R6::R6Class( # nolint: object_name_linter.
invisible(self)
},
#' @description Convert the `RcodeBlock` to a list.
#'
#' @return `named list` with a text and `params`.
#' @examples
#' block <- teal.reporter:::RcodeBlock$new()
#' block$to_list()
to_list = function() {
list(text = self$get_content(), params = self$get_params())
}
Expand Down
Loading
Loading