Skip to content
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

S3 diagnostics in subfolders #1553

Open
lionel- opened this issue Nov 23, 2023 · 3 comments
Open

S3 diagnostics in subfolders #1553

lionel- opened this issue Nov 23, 2023 · 3 comments

Comments

@lionel-
Copy link
Member

lionel- commented Nov 23, 2023

vdiffr has an R/svglite subfolder which is not documented but I still get a diagnostic from there:

✖ SVG.R:94: S3 method `print.svg` needs @export or @exportS3method
  tag.
@MichaelChirico
Copy link
Contributor

Noting for future readers: officially, only unix/ and windows/ subdirectories are supported:

https://cran.r-project.org/doc/manuals/R-exts.html#Package-subdirectories

The R and man subdirectories may contain OS-specific subdirectories named unix or windows.

I still get a diagnostic from there:

Can you clarify that this comes from running roxygen2::roxygenize() at the package top-level?

@MichaelChirico
Copy link
Contributor

MichaelChirico commented Oct 13, 2024

Reproduced: yes, it comes from top-level.

Interestingly, it's coming from roclet_process.roclet_namespace():

roxygen2/R/namespace.R

Lines 34 to 38 in 9652d15

roclet_process.roclet_namespace <- function(x, blocks, env, base_path) {
warn_missing_s3_exports(blocks, env)
blocks_to_ns(blocks, env)
}

where the blocks object does not include SVG.R:

sapply(blocks, `[[`, 'file') |> unique()
# [1] "R/expect-doppelganger.R"
# [2] "R/svg.R"                
 #[3] "R/vdiffr-package.R" 

But env does:

"print.svg" %in% names(env)
# [1] TRUE

That's coming from pkgload::load_all(), but even R CMD INSTALL puts that object in {vdiffr}'s NAMESPACE:

asNamespace("vdiffr")$print.svg
# function (x, ...) 
# cat(x, sep = "\n")
# <bytecode: 0x555f55f99850>
# <environment: namespace:vdiffr>

I can quite track down the R CMD build code responsible for this, but certainly the built package includes the svglite/ subdirectory:

R CMD build vdiffr
tar -tzf vdiffr_1.0.7.9000.tar.gz | grep "/R/."
# vdiffr/R/cpp11.R
# vdiffr/R/embed-svglite.R
# vdiffr/R/expect-doppelganger.R
# vdiffr/R/svg.R
# vdiffr/R/svglite/
# vdiffr/R/svglite/SVG.R
# vdiffr/R/svglite/inlineSVG.R
# vdiffr/R/svglite/utils.R
# vdiffr/R/utils.R
# vdiffr/R/vdiffr-package.R

So this looks like "roxygenize() fails to parse blocks in files that are included in the package sources"

@MichaelChirico
Copy link
Contributor

I tried simply editing r_files() to be recursive:

r_files <- function(path) {
sort_c(dir(file.path(path, "R"), "\\.[Rr]$", full.names = TRUE))
}

But that produces a different error when running roxygenize() in {vdiffr}:

roxygen2::roxygenize()
# ℹ Loading vdiffr
# Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
#   must specify DLL via a “DLLInfo” object. See getLoadedDLLs()
traceback()
# 7: stop(gettextf("must specify DLL via a %s object. See getLoadedDLLs()", 
#        dQuote("DLLInfo")), domain = NA)
# 6: getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE)
# 5: assignNativeRoutines(dlls[[lib]], lib, env, nsInfo$nativeRoutines[[lib]])
# 4: load_dll(path)
# 3: pkgload::load_all(path, helpers = FALSE, attach_testthat = FALSE)
# 2: load_code(base_path)
# 1: roxygen2::roxygenize()

Not pursuing this further for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants