Rd2roxygen: Convert all the Rd files of a package to roxygen comments

View source: R/rd2roxygen.R

Rd2roxygenR Documentation

Convert all the Rd files of a package to roxygen comments

Description

This function takes a package root directory, parses all its Rd files under the man directory and update the corresponding R source code by inserting roxygen documentation in to the R scripts.

Usage

Rd2roxygen(pkg, nomatch, usage = FALSE)

Arguments

pkg

the root directory of the package

nomatch

the file name (base name only) to use when an object in the Rd file is not found in any R source files (typically this happens to the data documentation); if not specified, the default will be ‘pkg’-package.R

usage

logical: whether to include the usage section in the output

Value

NULL (but the process of conversion will be printed on screen)

Note

ESS users may use options(roxygen.comment = "##' ") to ensure the generated roxygen comments begin with "##' ", which is the default setting in Emacs/ESS.

Re-run this function on a package will remove the previous roxygen comments before functions in R scripts.

Author(s)

Yihui Xie <http://yihui.org>

Examples

## a demo package
pkg = system.file("examples", "pkgDemo", package = "Rd2roxygen")
file.copy(pkg, tempdir(), recursive = TRUE)  # copy to temp dir first
od = setwd(tempdir())

## take a look at original R scripts
file.show("pkgDemo/R/foo.R")

options(roxygen.comment = "##' ")

## convert Rd's under man to roxygen comments
Rd2roxygen(file.path(tempdir(), "pkgDemo"))

file.show("pkgDemo/R/foo.R")  # what happened to foo.R and bar.R?

setwd(od)  # restore working directory

yihui/Rd2roxygen documentation built on April 16, 2024, 8:26 a.m.