diff --git a/R/ReportCard.R b/R/ReportCard.R index 41655f26..2498b12e 100644 --- a/R/ReportCard.R +++ b/R/ReportCard.R @@ -1,9 +1,9 @@ -#' @title `ReportCard` +#' @title `ReportCard`: An `R6` class for building report elements #' @docType class #' #' @description `r lifecycle::badge("experimental")` #' -#' `R6` class that supports creating a report card containing text, plot, table and +#' This `R6` class that supports creating a report card containing text, plot, table and #' metadata blocks that can be appended and rendered to form a report output from a `shiny` app. #' #' @export @@ -24,7 +24,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. }, #' @description Appends a table to this `ReportCard`. #' - #' @param table the appended table + #' @param table A (`data.frame` or object) that can be coerced into a table. #' @return `self`, invisibly. #' @examples #' card <- ReportCard$new()$append_table(iris) @@ -35,7 +35,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. }, #' @description Appends a plot to this `ReportCard`. #' - #' @param plot the appended plot + #' @param plot (`ggplot` or `grob` or `trellis`) plot object. #' @param dim (`integer(2)`) width and height in pixels. #' @return `self`, invisibly. #' @examplesIf requireNamespace("ggplot2") @@ -58,9 +58,9 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. self$append_content(pb) invisible(self) }, - #' @description Appends a paragraph of text to this `ReportCard`. + #' @description Appends a text paragraph to this `ReportCard`. #' - #' @param text (`character`) + #' @param text (`character`) The text content to add. #' @param style (`character(1)`) the style of the paragraph. One of: `default`, `header`, `verbatim` #' @return `self`, invisibly. #' @examples @@ -70,10 +70,10 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. self$append_content(TextBlock$new(text, style)) invisible(self) }, - #' @description Appends an `rmarkdown` R chunk to this `ReportCard`. + #' @description Appends an `R` code chunk to `ReportCard`. #' - #' @param text (`character`) - #' @param ... any `rmarkdown` R chunk parameter and its value. + #' @param text (`character`) The `R` code to include. + #' @param ... Additional `rmarkdown` parameters for formatting the `R` code chunk. #' @return `self`, invisibly. #' @examples #' card <- ReportCard$new()$append_rcode("2+2", echo = FALSE) @@ -82,9 +82,9 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. self$append_content(RcodeBlock$new(text, ...)) invisible(self) }, - #' @description Appends a `ContentBlock` to this `ReportCard`. + #' @description Appends a generic `ContentBlock` to this `ReportCard`. #' - #' @param content (`ContentBlock`) + #' @param content (`ContentBlock`) object. #' @return `self`, invisibly. #' @examples #' NewpageBlock <- getFromNamespace("NewpageBlock", "teal.reporter") @@ -95,7 +95,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. private$content <- append(private$content, content) invisible(self) }, - #' @description Returns the content of this `ReportCard`. + #' @description Get all content blocks from this `ReportCard`. #' #' @return `list()` list of `TableBlock`, `TextBlock` and `PictureBlock`. #' @examples @@ -107,7 +107,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. get_content = function() { private$content }, - #' @description Removes all objects added to this `ReportCard`. + #' @description Clears all content and metadata from `ReportCard`. #' #' @return `self`, invisibly. #' @@ -116,7 +116,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. private$metadata <- list() invisible(self) }, - #' @description Returns the metadata of this `ReportCard`. + #' @description Get the metadata associated with `ReportCard`. #' #' @return `named list` list of elements. #' @examples @@ -129,8 +129,8 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. }, #' @description Appends metadata to this `ReportCard`. #' - #' @param key (`character(1)`) name of meta data. - #' @param value value of meta data. + #' @param key (`character(1)`) string specifying the metadata key. + #' @param value value associated with the metadata key. #' @return `self`, invisibly. #' @examplesIf requireNamespace("ggplot2") #' ## ------------------------------------------------ @@ -154,7 +154,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. private$metadata <- append(private$metadata, meta_list) invisible(self) }, - #' @description get the card name. + #' @description Get the name of the `ReportCard`. #' #' @return `character` a card name. #' @examples @@ -162,7 +162,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. get_name = function() { private$name }, - #' @description set the card name. + #' @description Set the name of the `ReportCard`. #' #' @param name (`character`) a card name. #' @return `self`, invisibly. @@ -173,7 +173,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. private$name <- name invisible(self) }, - #' @description Convert the `ReportCard` to a list. + #' @description Convert the `ReportCard` to a list, including content and metadata. #' @param output_dir (`character`) with a path to the directory where files will be copied. #' @return (`named list`) a `ReportCard` representation. #' @examplesIf requireNamespace("ggplot2") @@ -211,7 +211,7 @@ ReportCard <- R6::R6Class( # nolint: object_name_linter. new_card[["metadata"]] <- self$get_metadata() new_card }, - #' @description Create the `ReportCard` from a list. + #' @description Reconstructs the `ReportCard` from a list representation. #' @param card (`named list`) a `ReportCard` representation. #' @param output_dir (`character`) with a path to the directory where a file will be copied. #' @return `self`, invisibly. diff --git a/man/ReportCard.Rd b/man/ReportCard.Rd index c5d7fb8f..5d36d327 100644 --- a/man/ReportCard.Rd +++ b/man/ReportCard.Rd @@ -3,11 +3,11 @@ \docType{class} \name{ReportCard} \alias{ReportCard} -\title{\code{ReportCard}} +\title{\code{ReportCard}: An \code{R6} class for building report elements} \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -\code{R6} class that supports creating a report card containing text, plot, table and +This \code{R6} class that supports creating a report card containing text, plot, table and metadata blocks that can be appended and rendered to form a report output from a \code{shiny} app. } \examples{ @@ -188,7 +188,7 @@ Appends a table to this \code{ReportCard}. \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{table}}{the appended table} +\item{\code{table}}{A (\code{data.frame} or object) that can be coerced into a table.} } \if{html}{\out{
}} } @@ -217,7 +217,7 @@ Appends a plot to this \code{ReportCard}. \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{plot}}{the appended plot} +\item{\code{plot}}{(\code{ggplot} or \code{grob} or \code{trellis}) plot object.} \item{\code{dim}}{(\code{integer(2)}) width and height in pixels.} } @@ -231,7 +231,7 @@ Appends a plot to this \code{ReportCard}. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-append_text}{}}} \subsection{Method \code{append_text()}}{ -Appends a paragraph of text to this \code{ReportCard}. +Appends a text paragraph to this \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$append_text(text, style = TextBlock$new()$get_available_styles()[1])}\if{html}{\out{
}} } @@ -239,7 +239,7 @@ Appends a paragraph of text to this \code{ReportCard}. \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{text}}{(\code{character})} +\item{\code{text}}{(\code{character}) The text content to add.} \item{\code{style}}{(\code{character(1)}) the style of the paragraph. One of: \code{default}, \code{header}, \code{verbatim}} } @@ -262,7 +262,7 @@ Appends a paragraph of text to this \code{ReportCard}. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-append_rcode}{}}} \subsection{Method \code{append_rcode()}}{ -Appends an \code{rmarkdown} R chunk to this \code{ReportCard}. +Appends an \code{R} code chunk to \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$append_rcode(text, ...)}\if{html}{\out{
}} } @@ -270,9 +270,9 @@ Appends an \code{rmarkdown} R chunk to this \code{ReportCard}. \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{text}}{(\code{character})} +\item{\code{text}}{(\code{character}) The \code{R} code to include.} -\item{\code{...}}{any \code{rmarkdown} R chunk parameter and its value.} +\item{\code{...}}{Additional \code{rmarkdown} parameters for formatting the \code{R} code chunk.} } \if{html}{\out{
}} } @@ -293,7 +293,7 @@ Appends an \code{rmarkdown} R chunk to this \code{ReportCard}. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-append_content}{}}} \subsection{Method \code{append_content()}}{ -Appends a \code{ContentBlock} to this \code{ReportCard}. +Appends a generic \code{ContentBlock} to this \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$append_content(content)}\if{html}{\out{
}} } @@ -301,7 +301,7 @@ Appends a \code{ContentBlock} to this \code{ReportCard}. \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{content}}{(\code{ContentBlock})} +\item{\code{content}}{(\code{ContentBlock}) object.} } \if{html}{\out{
}} } @@ -323,7 +323,7 @@ card <- ReportCard$new()$append_content(NewpageBlock$new()) \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-get_content}{}}} \subsection{Method \code{get_content()}}{ -Returns the content of this \code{ReportCard}. +Get all content blocks from this \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$get_content()}\if{html}{\out{
}} } @@ -348,7 +348,7 @@ card$get_content() \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-reset}{}}} \subsection{Method \code{reset()}}{ -Removes all objects added to this \code{ReportCard}. +Clears all content and metadata from \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$reset()}\if{html}{\out{
}} } @@ -361,7 +361,7 @@ Removes all objects added to this \code{ReportCard}. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-get_metadata}{}}} \subsection{Method \code{get_metadata()}}{ -Returns the metadata of this \code{ReportCard}. +Get the metadata associated with \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$get_metadata()}\if{html}{\out{
}} } @@ -393,9 +393,9 @@ Appends metadata to this \code{ReportCard}. \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{key}}{(\code{character(1)}) name of meta data.} +\item{\code{key}}{(\code{character(1)}) string specifying the metadata key.} -\item{\code{value}}{value of meta data.} +\item{\code{value}}{value associated with the metadata key.} } \if{html}{\out{
}} } @@ -407,7 +407,7 @@ Appends metadata to this \code{ReportCard}. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-get_name}{}}} \subsection{Method \code{get_name()}}{ -get the card name. +Get the name of the \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$get_name()}\if{html}{\out{
}} } @@ -428,7 +428,7 @@ get the card name. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-set_name}{}}} \subsection{Method \code{set_name()}}{ -set the card name. +Set the name of the \code{ReportCard}. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$set_name(name)}\if{html}{\out{
}} } @@ -456,7 +456,7 @@ set the card name. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-to_list}{}}} \subsection{Method \code{to_list()}}{ -Convert the \code{ReportCard} to a list. +Convert the \code{ReportCard} to a list, including content and metadata. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$to_list(output_dir)}\if{html}{\out{
}} } @@ -476,7 +476,7 @@ Convert the \code{ReportCard} to a list. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ReportCard-from_list}{}}} \subsection{Method \code{from_list()}}{ -Create the \code{ReportCard} from a list. +Reconstructs the \code{ReportCard} from a list representation. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{ReportCard$from_list(card, output_dir)}\if{html}{\out{
}} }