4
votes

I am learning Roxygen and making good progress so far. I've been able to document most of the package that I'm working on, but I've got a few places that I can't seem to get right. Please consider the following minimal R:

##' Test Roxygen Comments
##'
##' This is a test of the Roxygen System. Had this been actual
##' documentation, it may have contained information about the
##' directives and/or structures below.
##'
##' @name simple
##' @docType data
##' @rdname simple

variable <- list(
                 ##' itema comments
                 itema <- c("bing", "bang", "bong"),

                 ##' itemb comments
                 itemb <- "fooflakes"
)

##' More info abuot variable!
##' @rdname simple

The comments that are inside the list() are just dropped by Roxygen I've confirmed this with:

> parse.file("package-test/R/simple.R")
$`1`
$`1`$description
[1] "Test Roxygen Comments\n\nThis is a test of the Roxygen System. Had this been actual\ndocumentation, it may have contained information about the\ndirectives and/or structures below.\n\n"

$`1`$name
[1] "simple\n"

$`1`$docType
[1] "data"

$`1`$rdname
[1] "simple"

$`1`$assignee
[1] "variable"

$`1`$srcref
$`1`$srcref$filename
[1] "package-test/R/simple.R"

$`1`$srcref$lloc
[1] 11  1 17  1  1  1

I have an options setting infrastructure, for which I'd like to use Roxygen to document the individual options. It doesn't seem to matter whether or not I indent the comments, moving them flush-left doesn't seem to help. Adding @rdname to every block doesn't seem to help either. Am I just expecting behavior that doesn't exist? In another question, the accepted answer said we could put Roxygen comments anywhere and that they would be collected.

So two fold: what am I missing above, and how do other people document individual data items if not like my attempt?

Thank you!

1
You're expecting behaviour that doesn't exist. - hadley
I'm more of a newbie at Roxygen than most, but I'll stick my neck out. What doesn't exist; adding Roxygen comment lines inline with your code instead of as a block above your code, or using roxygen to document a list, or adding comments inside a code structure and expecting Roxygen to work out what they refer to ? (or all three ???) - PaulHurleyuk

1 Answers

4
votes

Roxygen does not do that. I need 5 more characters to be an official answer.