Skip to content

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

Open
@DavisVaughan

Description

@DavisVaughan

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementrd ✍️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions