Roxygen2: (new to 5.0) @export fails to export if there is another #' before the function/object

Created on 28 Oct 2015  Â·  11Comments  Â·  Source: r-lib/roxygen2

This is new. I can work around it by removing said formatting, but it seems rather brittle and flaky.

Most helpful comment

@hadley @klutometis This is still not working for me. I have to move #' @export above another roxygen2 tag to make it work. From a fresh session details below.

Intriguingly, the bug is itself buggy. That is, it doesn't reproduce consistently. For example

file1.R
#' @title ...
... blah blah ...
#' @export
foo <- function(a,b,c) {<some function>} # works fine

file2.R
#' @title ...
... blah blah ...
#' @export
foo2 <- function(a,b,c) {<some function>} # doesn't work, but 

file2.R
#' @title ...
... blah blah ...
#' @export
#' <any other roxygen tag, such as examples or reference>
foo <- function(a,b,c) {<some function>} # works fine
> devtools::document()
Updating synthACS documentation
Loading synthACS
Warning: @export [pull_synth_data.R#12]: may only span a single line
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] synthACS_1.2.5      testthat_2.0.0      data.table_1.10.4-3 acs_2.1.3           XML_3.98-1.10      
[6] stringr_1.3.0      

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16     rstudioapi_0.7   xml2_1.2.0       magrittr_1.5     roxygen2_6.0.1   devtools_1.13.4 
 [7] R6_2.2.2         rlang_0.1.6      httr_1.3.1       plyr_1.8.4       tools_3.4.3      withr_2.1.1     
[13] commonmark_1.4   yaml_2.1.16      digest_0.6.15    assertthat_0.2.0 rprojroot_1.3-2  crayon_1.3.4    
[19] memoise_1.1.0    stringi_1.1.7    compiler_3.4.3   backports_1.1.2  desc_1.1.1      

All 11 comments

Could you please provide a reproducible example?

sure, see ttriche/roxpkg , specifically hello.R and goodbye.R

The comment about \@export spanning more than one line seems to be new(ish) and wasn't getting thrown previously (in the package I was working on earlier), just mysteriously not exporting anything.

Could you please include a reproducible example inline?

How? The problem occurs when I run devtools::document() or
roxygen2::roxygenise() from within the package root.

That's also how I was most easily able to reproduce the problem. I'm not
sure how to provide an inline example of an error that seems to occur in a
context-dependent fashion. If there's a trailing #' after #' @export, the
function isn't exported. This behavior is new. That's all I'm saying.

The repo that I threw up demonstrates it in the simplest way I could think
of.

--t

On Wed, Oct 28, 2015 at 3:25 PM, Hadley Wickham [email protected]
wrote:

Could you please include a reproducible example inline?

—
Reply to this email directly or view it on GitHub
https://github.com/klutometis/roxygen/issues/415#issuecomment-152016298.

Copy and paste the code from your repo into this issue. Or at least paste a link to the file within the repo.

In the past, there was no difference between the following re: NAMESPACE. Now, there is.

#' Hi, I'm exported!
#'
#' @param txt       what to say
#'
#' @export
hello <- function(txt = "world") {
    cat("Hello, ", txt, "\n")
}
#' Hi, I'm not exported!
#'
#' @param txt       what to say
#'
#' @export
#'
goodbye <- function(txt = "world") {
    cat("Goodbye, ", txt, "\n")
}

Thanks - that's helpful. The fewer links I need to follow, the faster I can fix the problem - in future, it would also be helpful if you include the text of the error message. That makes it even faster for me to track down.

Thanks!

--t

On Oct 29, 2015, at 6:18 AM, Hadley Wickham [email protected] wrote:

Closed #415 via 361c84e.

—
Reply to this email directly or view it on GitHub.

@hadley @klutometis This is still not working for me. I have to move #' @export above another roxygen2 tag to make it work. From a fresh session details below.

Intriguingly, the bug is itself buggy. That is, it doesn't reproduce consistently. For example

file1.R
#' @title ...
... blah blah ...
#' @export
foo <- function(a,b,c) {<some function>} # works fine

file2.R
#' @title ...
... blah blah ...
#' @export
foo2 <- function(a,b,c) {<some function>} # doesn't work, but 

file2.R
#' @title ...
... blah blah ...
#' @export
#' <any other roxygen tag, such as examples or reference>
foo <- function(a,b,c) {<some function>} # works fine
> devtools::document()
Updating synthACS documentation
Loading synthACS
Warning: @export [pull_synth_data.R#12]: may only span a single line
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] synthACS_1.2.5      testthat_2.0.0      data.table_1.10.4-3 acs_2.1.3           XML_3.98-1.10      
[6] stringr_1.3.0      

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16     rstudioapi_0.7   xml2_1.2.0       magrittr_1.5     roxygen2_6.0.1   devtools_1.13.4 
 [7] R6_2.2.2         rlang_0.1.6      httr_1.3.1       plyr_1.8.4       tools_3.4.3      withr_2.1.1     
[13] commonmark_1.4   yaml_2.1.16      digest_0.6.15    assertthat_0.2.0 rprojroot_1.3-2  crayon_1.3.4    
[19] memoise_1.1.0    stringi_1.1.7    compiler_3.4.3   backports_1.1.2  desc_1.1.1      

Observing the same behavior as "I have to move #' @export above another roxygen2 tag to make it work." with current version 6.1.0.9000.

@zkurtz commenting on closed issues usually will not get you very far. Can you please open a new issue with a reproducible example? Or some of the examples above fail for you?

Was this page helpful?
0 / 5 - 0 ratings