Skip to contents

Inspired by document::document(), this package combines calls to usethis::create_package() and roxygen2::roxygenise() to create a temporary package based on a R script or directory of R scripts using roxygen documentation. The scripts are loaded and the documentation is accessible within RStudio using ?.

Usage

path_document(
  path,
  pkg = NULL,
  fields = list(),
  tmp_dir = tempdir(),
  markdown = TRUE,
  overwrite = FALSE,
  roclets = NULL,
  load_code = NULL,
  clean = FALSE,
  quiet = FALSE,
  allow_file = TRUE,
  regexp = "\\.[rR]$"
)

path_roxygenise(
  path,
  pkg = NULL,
  fields = list(),
  tmp_dir = tempdir(),
  markdown = TRUE,
  overwrite = FALSE,
  roclets = NULL,
  load_code = NULL,
  clean = FALSE,
  quiet = FALSE,
  allow_file = TRUE,
  regexp = "\\.[rR]$"
)

Arguments

path

A character vector of one or more paths.

pkg

Package name. Optional.

fields

A named list of fields to add to DESCRIPTION, potentially overriding default values. See use_description() for how you can set personalized defaults using package options.

tmp_dir

Directory where temporary package is created. Defaults to tempdir().

markdown

If TRUE (default), use usethis::use_roxygen_md() to ensure that Markdown formatted roxygen comments are converted.

overwrite

Default FALSE. If TRUE, overwrite the NAMESPACE file and any R scripts at the same location sharing the same names.

roclets

Character vector of roclet names to use with package. The default, NULL, uses the roxygen roclets option, which defaults to c("collate", "namespace", "rd").

load_code

A function used to load all the R code in the package directory. The default, NULL, uses the strategy defined by the load roxygen option, which defaults to load_pkgload(). See load for more details.

clean

If TRUE, roxygen will delete all files previously created by roxygen before running each roclet.

quiet

If TRUE, suppress messages from usethis and cli calls. This function always suppresses package startup messages when the package is loaded by roxygen2::roxygenise().

allow_file

If TRUE, path_document() allows both file and directory input paths. If FALSE, function errors on file path inputs.

regexp

A regular expression (e.g. [.]csv$) passed on to grep() to filter paths.