-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document
generates wrong S3 exports if NAMESPACE doesn’t exist yet
#1585
Comments
The easy solution is as you noted to just run Having to run |
Fair enough, that’s an acceptable solution if it’s clearly documented. I’m wondering if it’s actually necessary to load the package so meticulously when generating the … But I’m probably overlooking some corner cases where that would yield wrong results, am I not? |
The long term solution is here: r-lib/roxygen2#372 |
Also FWIW the only reason that |
@jimhester |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
My package ‹modules› has an insidious bug related to incorrect exports of S3 methods, generated via roxygen2. However, the roxygen2 tags inside my package are correct:
The problem is that my deployment process (which generates the documentation) starts from a blank slate, i.e. no
NAMESPACE
file exists yet. As a consequence, even though theImports
are correctly listed in theDESCRIPTION
, devtools fails to import the necessary S3 generic which my method extends. Subsequently roxygen2 fails to recognise that these methods are, indeed, S3 methods; and it generates the followingNAMESPACE
entry:export(roclet_tags.roclet_export)
To reproduce this issue:
Generate an empty package using
Rscript -e 'dummy = 1; package.skeleton("foo", "dummy")'
cd foo
Add imports:
echo 'Imports: roxygen2' >> DESCRIPTION
rm NAMESPACE
Add a new file
R/test.r
with the contentsRun
Rscript -e 'devtools::document()'
Expected output:
Actual output:
Running
Rscript -e 'devtools::document()'
a second time yields a correctedNAMESPACE
file.I am reporting this bug here since using
roxygen2::roxygenize()
instead ofdevtools::document()
actually works:roxygen2::roxygenize
is “dumber” and performs less sophisticated loading.devtools::load_all
, by contrast, is “too smart” and attempts to use the (non-existent)NAMESPACE
as a hint for loading. This is fundamentally circular and, though a good heuristic, bound to produce false results on occasion.Unfortunately devtools gives no indication of potential problems, and the result is very hard to debug failures (see linked bug report): I took several days of trial and error and going through roxygen2 and devtools internals to find the problem; if I hadn’t already known my way around both code bases this would have taken even longer.
At the very least
document
should produce a clear warning about potentially mis-classifying S3 methods; even better would be a way of controlling the behaviour so that a single pass ofdocument
produces the correct output.The text was updated successfully, but these errors were encountered: