Rd2roxygen {Rd2roxygen}R 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.name>

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

[Package Rd2roxygen version 1.4.2 Index]