Description
Running roxygenize
on a package with undocumented S3 methods and without srcrefs fails as follows:
Error in map2(undocumented, names(undocumented), function(fun, name) { :
ℹ In index: 1.
ℹ With name: c.blah.
Caused by error in `basename()`:
! a character vector argument expected
The error relates to the addition of checks for undocumented S3 methods from #1534 which implicitly assumes srcrefs are always present. Downstream code then fails because it gets NULL instead of a string.
Recreating the error is a bit tricky b/c we need a package without srcrefs, but here is a reasonably small example that reproduces the error:
pkg.name <- 'pkguqhr'
DESCRIPTION <- sprintf('
Package: %s
Version: 0.0
Encoding: UTF-8
Roxygen: list(load="installed")', pkg.name)
NAMESPACE <- ''
RCODE <- 'c.blah <- function(...) NULL'
if(!pkg.name %in% rownames(installed.packages())) {
pkg.dir <- tempfile(pkg.name)
dir.create(file.path(pkg.dir, "R"), recursive=TRUE)
writeLines(DESCRIPTION, file.path(pkg.dir, 'DESCRIPTION'))
writeLines(NAMESPACE, file.path(pkg.dir, 'NAMESPACE'))
writeLines(RCODE, file.path(pkg.dir, 'R', 'pkg.R'))
install.packages(pkg.dir, type='src', repos=NULL, quiet=TRUE)
try(roxygen2::roxygenise(pkg.dir))
remove.packages(pkg.name)
} else {
stop(
"Please either remove ", pkg.name,
" or find another name for this test package"
)
}
Notice the Roxygen: list(load="installed")
. Assuming the above is in test.R
then:
R --vanilla -q -f test.R
Reproduces the error.
Relates to #1589. #1711 provides a simple fix, but probably better would be to have an accessor function for srcrefs that is guaranteed to return in standard format, and then use that function everywhere, but that's a bigger change.