Skip to contents

Generate documentation from R scripts

Usage

fundoc(
  scripts = ".",
  out_dir = "docs",
  proj_name = NULL,
  proj_title = NULL,
  version = NULL,
  quiet = FALSE
)

Arguments

scripts

A character vector of paths. The vector can be a mix of either (1) directory paths, (2) file paths, or (3) glob expressions to R scripts. Note that (2) and (3) must end with .R or .r. See expand_Rscript() for details.

proj_name

Character. The name of the project. Must conform to conventions of naming R packages. To check whether a name is valid, refer to https://github.com/r-lib/available. Defaults to NULL, which generates the name Foo.{YYYY.MM.DD} according to the current date.

proj_title

Character. A one-sentence title of what the project does. Defaults to NULL, which generates a title of the format: Function documentation of project {proj_name}.

version

Character. Version number of the project. Defaults to "0.0.1" when set to NULL.

quiet

Logical. Whether to hide messages from the subprocess compiling the function documentation. Defaults to FALSE.

outdir

Path to the generated documentation directory.

Examples

Rscript = "
#' A Foo function
#'
#' Just an example
#'
#' @param x Character. Calling `foo()` prints out `x`.
#' @export
#' @examples
#' foo('Hello World!')
foo <- function(x) print(x)
"
tmp <- paste0(tempfile(), ".R")
writeLines(Rscript, tmp)

fundoc(scripts = tmp,
       out_dir = "docs",
       proj_name = "fundoc",
       proj_title = "Quick and Dirty Function Documentation",
       quiet = TRUE)
#> Documenting functions in: 
#>   C:\Users\rd\AppData\Local\Temp\Rtmp4oYZ6V\filecfcc44234fa0.R
#> Function documentation saved to C:/Users/rd/Desktop/fundoc/docs/reference/docs