roxygen2 icon indicating copy to clipboard operation
roxygen2 copied to clipboard

Invalid `@usage` section generated for data objects when `LazyData: false` is set

Open DavisVaughan opened this issue 3 years ago • 1 comments

This stack overflow answer of mine continue to get upvotes, so I think this is probably a roxygen2 bug https://stackoverflow.com/questions/57396392/warning-variables-with-usage-in-documentation-object-fang-but-not-in-code/57396393#57396393

When LazyData: false is set and you have a data object, then roxygen2 generates an invalid @usage section that check() complains about with the following warning:

❯ checking for code/documentation mismatches ... WARNING
  Variables with usage in documentation object 'mydata' but not in code:
    ‘mydata’

The usage section that gets generated looks like:

\usage{
mydata
}

but to be valid when LazyData: false is set, it should be something like:

\usage{
data(mydata)
}

I've created a test package for this bug: https://github.com/DavisVaughan/testroxygen2usage

It is currently in a state where things are broken, i.e. check() gives that warning. It has LazyData: false set and a documented data set, mydata, in mydata.R. You can manually "fix" it in two ways:

  • Set LazyData: true
  • Manually override usage with @usage data(mydata)

DavisVaughan avatar Aug 31 '22 19:08 DavisVaughan

Bumping this issue since this is still a problem and BioConductor requires us to set LazyData to false.

AliSajid avatar Jun 25 '24 19:06 AliSajid