R/abstract_report_template.R

#' Convert to an HTML vignette.
#' 
#' A HTML vignette is a lightweight alternative to \code{\link{html_document}}
#' suitable for inclusion in packages to be released to CRAN. It reduces the
#' size of a basic vignette from 100k to around 10k.
#' 
#' Compared to \code{html_document}, it:
#' 
#' \itemize{
#'   \item never uses retina figures
#'   \item has a smaller default figure size
#'   \item uses a custom css stylesheet
#'  }
#'
#' @details
#'
#' See the \href{http://rmarkdown.rstudio.com/package_vignette_format.html}{online
#' documentation} for additional details on using the \code{html_vignette} format.
#' 
#' @inheritParams html_document
#' @return R Markdown output format to pass to \code{\link{render}}
#' @export
abstract_report <- function(fig_width = 3,
                          fig_height = 3,
                          dev = 'png',
                          css = NULL,
                          template = NULL,
                          ...) {
  
  if (is.null(css)) {
    css <- system.file("rmarkdown", "templates", "abstract_report_template" ,"resources", 
                       "abstract_report.css", package = "reporteR")
  }
  
  if (is.null(template)) {
    template <- system.file("rmarkdown", "templates", "abstract_report_template" ,"resources", 
                       "abstract_report.html5", package = "reporteR")
  }
  
  rmarkdown::html_document(fig_width = fig_width,
                fig_height = fig_height, 
                dev = dev,
                fig_retina = FALSE,
                css = css, 
                template = template,
                theme = NULL,
                highlight = "pygments",
                ...)
}
psobczyk/reporteR documentation built on May 26, 2019, 10:33 a.m.