2

I imagine this is a simple thing that I keep overlooking in the documentation, but I can't seem to figure out how to get package-level documentation to work in R. I'm not referring to function or class-specific documentation, but the documentation that you get when you type, for example, ?stats.

I've followed the general instructions I've found on the web, creating a sckeleton documentation file saved as .R. The .R file is copied with the package scripts, but the help documentation doesn't get made into a .Rd file (unless I add a function definition also named after the package).

An example of what I've tried:

#'_PACKAGE
#'MyPackage
#'
#'MyPackage description
#'
#'MyPackage details
#'@alias{MyPackage}
#'@alias{MyPackage-package}

I'm having a hard time finding good examples of how to set up general package documentation, for some reason. I've written quite a few function help files, and I know my package help file is being found by roxygen, but it's unclear why I can't generate an .Rd from it.

Joel Graff
  • 167
  • 15
  • 1
    You do need a `NULL` on the line following your documentation. [See here](http://r-pkgs.had.co.nz/man.html#man-packages) for an example. – Josh O'Brien Dec 23 '15 at 16:50
  • 1
    You may want to alter the title of your question. This is not a 'overall package documentation'. You know how to do this in a Rd file -- this is about a specific aspect of roxygen2. – Dirk Eddelbuettel Dec 23 '15 at 16:52
  • 1
    @slickrickulicious Agreed. Try also `identical(NULL, {})` to see why both work equally well. – Josh O'Brien Dec 23 '15 at 16:57
  • 2
    Updated title as well. I was trying to avoid comments on how to document for functions rather than the package as a whole. – Joel Graff Dec 23 '15 at 16:59
  • Edit of original comment: Added curly braces around '\name' when I shouldn't have. After removing, it worked! – Joel Graff Dec 23 '15 at 17:06

2 Answers2

2

Answer courtesy of @slickrickulicious in the comments above:

I needed to add NULL at the end of my documentation file and include '@name MyPackage'. Doing so generated the package help file correctly.

Joel Graff
  • 167
  • 15
0

I made my package (called pkgName) using devtools and already had a file named pkgName_package.R that was automatically generated. It contained the following lines:

#' @keywords internal
#' @aliases pkgName-package
"_PACKAGE"

After removing the first line, @keywords internal, and rebuilding, pkgName-package was a documented topic that appeared at the top of the reference manual.

Jacob Helwig
  • 41
  • 1
  • 5