R/diff_rmd_addin.R

Defines functions diff_rmd_addin

Documented in diff_rmd_addin

#' Rstudio addin to display the raw (unrendered) differences between two
#' rmarkdown files
#'
#' This addin is a small wrapper for \code{diff_rmd()}.  
#'
#' @return Displays viewable html of the diff in the RStudio Viewer pane. If
#'   file is identical to previous version a message is provided. This may occur
#'   if changes since the last commit haven't been saved.
#'
#' @export
diff_rmd_addin <- function() {
  content <- rstudioapi::getActiveDocumentContext()
  x <- diff_rmd(content$path)
  if (!is.null(x$raw)) {
    rstudioapi::viewer(x$raw) 
  }
}
ropenscilabs/reviewer documentation built on May 17, 2022, 2:07 p.m.