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

Collate Section of DESCRIPTION Incorrectly Parsed in roxygen 6.1 #790

Closed
brodieG opened this issue Sep 10, 2018 · 0 comments
Closed

Collate Section of DESCRIPTION Incorrectly Parsed in roxygen 6.1 #790

brodieG opened this issue Sep 10, 2018 · 0 comments

Comments

@brodieG
Copy link
Contributor

brodieG commented Sep 10, 2018

Documentation build no longer works with (some?) packages with a collate section in description (update: it seems to be packages that list one file per line in the collate field with indenting). Here is an example against the current master of ggplot2, although I've seen the same thing with one of my packages:

> devtools::document()
Updating ggplot2 documentation
Loading ggplot2
Error in parse(text = lines, keep.source = TRUE, srcfile = srcfilecopy(file,  : 
  /Volumes/PERSONAL/repos/ggplot2/R:1:12: unexpected numeric constant
1: .          0
               ^
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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] ggplot2_3.0.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18        compiler_3.5.1      pillar_1.3.0.9000  
 [4] plyr_1.8.4          bindr_0.1.1         tools_3.5.1        
 [7] testthat_2.0.0      digest_0.6.15       memoise_1.1.0      
[10] tibble_1.4.99.9003  nlme_3.1-137        gtable_0.2.0       
[13] lattice_0.20-35     viridisLite_0.3.0   mgcv_1.8-24        
[16] pkgconfig_2.0.2     rlang_0.2.2         Matrix_1.2-14      
[19] commonmark_1.5      bindrcpp_0.2.2      withr_2.1.2        
[22] stringr_1.3.1       dplyr_0.7.6         roxygen2_6.1.0.9000
[25] xml2_1.2.0          desc_1.2.0          devtools_1.13.6    
[28] rprojroot_1.3-2     grid_3.5.1          tidyselect_0.2.4   
[31] glue_1.3.0          R6_2.2.2            purrr_0.2.5        
[34] reshape2_1.4.3      magrittr_1.5        backports_1.1.2    
[37] scales_0.5.0        MASS_7.3-50         assertthat_0.2.0   
[40] colorspace_1.3-2    stringi_1.2.3       lazyeval_0.2.1     
[43] munsell_0.5.0       crayon_1.3.4       

I believe this can be traced to the change to use desc::desc.

I have a PR coming shortly that should fix the issue.

Fundamentally, the problem is that the new method of pulling the description does not trim whitespace. The old method used read.dcf:

> read.dcf('DESCRIPTION')
     Package Title                                         
[1,] "fansi" "ANSI Control Sequence Aware String Functions"
... SNIP ....
     Collate                                                                                                                                                                            
[1,] "'constants.R'\n'fansi-package.R'\n'has.R'\n'internal.R'\n'load.R'\n'misc.R'\n'nchar.R'\n'strip.R'\n'strwrap.R'\n'strtrim.R'\n'strsplit.R'\n'substr2.R'\n'tohtml.R'\n'unhandled.R'"

The new method keeps the whitespace padding:

> roxygen2:::read.description('DESCRIPTION')
$Package
[1] "fansi"

$Title
[1] "ANSI Control Sequence Aware String Functions"

... SNIP ...

$Collate
[1] "'constants.R'\n    'fansi-package.R'\n    'has.R'\n    'internal.R'\n    'load.R'\n    'misc.R'\n    'nchar.R'\n    'strip.R'\n    'strwrap.R'\n    'strtrim.R'\n    'strsplit.R'\n    'substr2.R'\n    'tohtml.R'\n    'unhandled.R'"

Which then leads to this file listing:

debugging in: package_files(path)
debug: {
    desc <- read_pkg_description(path)
    all <- normalizePath(r_files(path))
    collate <- scan(text = desc$Collate %||% "", what = "", sep = " ", 
        quiet = TRUE, strip.white = TRUE)
    collate <- normalizePath(file.path(path, "R", collate))
    rfiles <- c(collate, setdiff(all, collate))
    ignore_files(rfiles, path)
}
Browse[2]> 
debug: desc <- read_pkg_description(path)
Browse[2]> 
debug: all <- normalizePath(r_files(path))
Browse[2]> 
debug: collate <- scan(text = desc$Collate %||% "", what = "", sep = " ", 
    quiet = TRUE, strip.white = TRUE)
Browse[2]> 
debug: collate <- normalizePath(file.path(path, "R", collate))
Browse[2]> collate
 [1] "constants.R"     ""                ""                ""               
 [5] ""                "fansi-package.R" ""                ""               
 [9] ""                ""                "has.R"           ""               
[13] ""                ""                ""                "internal.R"     
[17] ""                ""                ""                ""               
[21] "load.R"          ""                ""                ""               
[25] ""                "misc.R"          ""                ""               
[29] ""                ""                "nchar.R"         ""               
[33] ""                ""                ""                "strip.R"        
[37] ""                ""                ""                ""               
[41] "strwrap.R"       ""                ""                ""               
[45] ""                "strtrim.R"       ""                ""               
[49] ""                ""                "strsplit.R"      ""               
[53] ""                ""                ""                "substr2.R"      
[57] ""                ""                ""                ""               
[61] "tohtml.R"        ""                ""                ""               
[65] ""                "unhandled.R" 

which then causes the error when R tries to read the R directory as a file.

This is likely the source of #785 as well.

The only thing that gives me pause in all this is that there are not more reports of this issue here given how long 6.1 has been out, so maybe I am doing something wrong.

It is possible this was not caught because the tests use a "collate" field where the file names are all on one line and no indents (i.e. tests/description-example.txt).

@hadley hadley closed this as completed in cc34200 Sep 12, 2018
colinpmillar added a commit to flr/FLa4a that referenced this issue Oct 20, 2018
Needed to go to devel version due to r-lib/roxygen2#790
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

1 participant