R/pkg_rd.R

Defines functions pkg_rd

Documented in pkg_rd

#' Create a Boilerplate Package `Rd` Function Documentation
#'
#' Creates a boilerplate package `Rd` function documentation.
#'
#' Note that if [jeksterslabRpkg::pkg_create()] is used,
#' this function will be called.
#'
#' If you are going to document, check, and build your package using `devtools`,
#' you may delete the `Rd` function documentation file generated by this function.
#'
#' @author Ivan Jacob Agaloos Pesigan
#' @inheritParams pkg_rbuildignore
#' @examples
#' \dontrun{
#' pkg_rd(
#'   pkg_root = "~/boilerplatePackage"
#' )
#' }
#' @export
pkg_rd <- function(pkg_root,
                   msg = "z.Rd file path:") {
  root_man <- file.path(
    pkg_root,
    "man"
  )
  output <- paste0(
    readLines(
      con = system.file(
        "extdata",
        "zRd",
        package = "jeksterslabRpkg",
        mustWork = TRUE
      )
    ),
    collapse = "\n"
  )
  output <- paste0(
    "% This is a boilerplate example.",
    "\n",
    "% Delete this file if you are building documentation files with roxygen.",
    "\n",
    output
  )
  util_txt2file(
    text = output,
    dir = root_man,
    fn = "z.Rd",
    msg = msg,
    overwrite = TRUE
  )
}
jeksterslabds/jeksterslabRpkg documentation built on Jan. 22, 2021, 11:43 p.m.