R/preview.R

Defines functions preview_docsify

Documented in preview_docsify

#' Preview the documentation in a webpage or in viewer
#'
#' This runs a preview of the site generated by docsify.js in RStudio viewer. This function must be called after having created the essential files with `init_docsify()`.
#'
#' @return Runs a preview of the site generated by docsify.js in RStudio viewer.
#' @export
#' @examples
#' \dontrun{
#'
#' library(docsifier)
#'
#' # Create a test folder and a test package for the example
#'
#' test_folder <- tempdir()
#' setwd(test_folder)
#' devtools::create("dummy")
#' setwd("dummy")
#'
#' # Generate the minimal documentation for docsify.js
#'
#' init_docsify()
#'
#' # Run the preview
#'
#' preview_docsify()
#' }
preview_docsify <- function() {

  if (!fs::file_exists("docs/index.html")) {
    stop("index.html was not found. You can run init_docsify() to create it.")
  }

  servr::httw("docs/")

}
etiennebacher/docsifier documentation built on Feb. 21, 2022, 2:20 p.m.