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

pkgdown 1.1.0 does not process \doi tags #720

Closed
strengejacke opened this issue Jun 6, 2018 · 25 comments
Closed

pkgdown 1.1.0 does not process \doi tags #720

strengejacke opened this issue Jun 6, 2018 · 25 comments
Labels

Comments

@strengejacke
Copy link

@strengejacke strengejacke commented Jun 6, 2018

When I use build_site() with my package (https://github.com/strengejacke/sjstats), I get following error for pkgdown 1.1.0:

Reading 'man/deff.Rd'
Error: x must be a string or a R connection
Execution halted

Reverting to pkgdown 1.0.0 solves the problem, there's no error then.

@jayhesselberth

This comment has been hidden.

@strengejacke

This comment has been hidden.

@strengejacke

This comment has been hidden.

@aqualogy

This comment has been hidden.

@KasperSkytte

This comment has been hidden.

@jayhesselberth

This comment has been hidden.

@strengejacke

This comment has been hidden.

@jayhesselberth

This comment has been hidden.

@aqualogy

This comment has been hidden.

@strengejacke

This comment has been hidden.

@KasperSkytte

This comment has been hidden.

@jayhesselberth
Copy link
Collaborator

@jayhesselberth jayhesselberth commented Jun 15, 2018

One problem is the \doi tag. A minimal package with only the file:

#' \doi{blah}
test <- function() {}

triggers Error: x must be a string or a R connection.

For reference:

devtools::load_all("~/devel/pkgdown")
#> Loading pkgdown

rd_text("\\doi{10.1177/0163278703255230}")
#> \Sexpr[results=rd,stage=build]{tools:::Rd_expr_doi("#1")}10.1177/0163278703255230[results=rd,stage=build]{tools:::Rd_expr_doi("10.1177/0163278703255230")}

tools:::Rd_expr_doi("10.11177/0163278703255230")
#> [1] "\\ifelse{text}{doi: 10.11177/0163278703255230 (URL: http://doi.org/10.11177/0163278703255230)}{\\ifelse{latex}{doi:\\out{\\nobreakspace{}}\\href{http://doi.org/10.11177/0163278703255230}{10.11177\\out{\\slash{}}0163278703255230}}{doi: \\href{http://doi.org/10.11177/0163278703255230}{10.11177/0163278703255230}}}"

# rd2html deals with this OK
rd2html(tools:::Rd_expr_doi("10.11177/0163278703255230"))
#> [1] "doi: <a href='http://doi.org/10.11177/0163278703255230'>10.11177/0163278703255230</a>"

Created on 2018-06-15 by the reprex package (v0.2.0).

@jayhesselberth jayhesselberth added bug and removed reprex labels Jun 15, 2018
@strengejacke
Copy link
Author

@strengejacke strengejacke commented Jun 15, 2018

I haven't checked systematically yet, but I can confirm that for all .rd-file I remember where an error occured, these also contained a doi-tag.

@jayhesselberth jayhesselberth changed the title Error after updating to version 1.1.0 Support \doi Rd tag Jun 15, 2018
@jayhesselberth jayhesselberth changed the title Support \doi Rd tag Parse \doi Rd tag Jun 15, 2018
@aqualogy
Copy link

@aqualogy aqualogy commented Jun 15, 2018

In the meantime I have also prepared an example package:

https://github.com/aqualogy/pdtest720

First I suspected the Rdpack macro \insertRef as error source, but in the meantime I can confirm the Rd-files \doi tag as error source, too. During execution of _build.R build_site() fails for df.flys4.Rd, which is the first of five variations of df.flys?.Rd that includes the \doi tag. The three previous versions (df.flys1.Rd, df.flys2.Rd, df.flys3.Rd) work well, the later two with \doi tag or \insertRef tag fail.

@KasperSkytte Since I used to explicitely overwrite the destination of the output to a subdirectory of public/ (Gitlab's standard directory for static html output) depending on the R version (public/R-3.5.0/), I didn't expect to get a directory docs/ produced by build_site(). In the meantime I have reported this as separate issue: #734

@KasperSkytte
Copy link

@KasperSkytte KasperSkytte commented Jun 15, 2018

I removed \doi{} tags and now it runs perfectly. Who would have known. Thanks for the quick responses!

@strengejacke
Copy link
Author

@strengejacke strengejacke commented Jun 15, 2018

so what has changed with the parsing, as all works well in version 1.0.0?

@jayhesselberth
Copy link
Collaborator

@jayhesselberth jayhesselberth commented Jun 15, 2018

Hmm, good question. Your DOI links were previously linked just fine using 1.0.0.

https://strengejacke.github.io/sjstats/reference/deff.html#references

It's most likely a change in rd-html.R between v1.0.0...v1.1.0

This test needs to pass:

test_that("DOIs are linked", {
  expect_equal(
    rd2html("\\doi{10.1177/0163278703255230}"),
    "doi: <a href='http://doi.org/10.11177/0163278703255230'>10.11177/0163278703255230</a>"
  )
})

@jayhesselberth jayhesselberth changed the title Parse \doi Rd tag pkgdown 1.1.0 does not process \doi tags Jun 16, 2018
@aravind-j
Copy link

@aravind-j aravind-j commented Jun 19, 2018

The tag \insertRef of the Rd macro Rdpack is also not parsed and generates the same error.

jayhesselberth added a commit that referenced this issue Jun 20, 2018
Sexpr with multiple args \Sexpr[results=rd,stage=build] were not parsed correctly

Closes #720
@jayhesselberth
Copy link
Collaborator

@jayhesselberth jayhesselberth commented Jun 20, 2018

\doi should be fixed by #738. Can someone confirm whether \insertRef is also fixed?

@aqualogy
Copy link

@aqualogy aqualogy commented Jun 20, 2018

Not yet! After updating to current master (devtools::install_github("R-lib/pkgdown")) I still get an error at the first occurences of \doi and \insertRef.

sessionInfo()
R version 3.5.0 (2018-04-23) Platform: x86_64-redhat-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] rmarkdown_1.10 knitr_1.20 devtools_1.13.5 pdtest720_0.1.0
[5] pkgdown_1.1.0.9000

loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 xml2_1.2.0 magrittr_1.5 roxygen2_6.0.1
[5] MASS_7.3-50 debugme_1.1.0 R6_2.2.2 rlang_0.2.1
[9] bibtex_0.4.2 stringr_1.3.1 tools_3.5.0 withr_2.1.2
[13] htmltools_0.3.6 commonmark_1.5 yaml_2.1.19 assertthat_0.2.0
[17] digest_0.6.15 rprojroot_1.3-2 tibble_1.4.2 crayon_1.3.4
[21] processx_3.1.0 callr_2.0.4 purrr_0.2.5 Rdpack_0.8-0
[25] fs_1.2.3 gbRd_0.4-11 memoise_1.1.0 evaluate_0.10.1
[29] stringi_1.2.3 compiler_3.5.0 pillar_1.2.3 desc_1.2.0
[33] backports_1.1.2

traceback
5: stop(err[[2]]) 4: get_result(output = out, options) 3: callr::r(function(...) pkgdown::build_site(...), args = args, show = TRUE) 2: build_site_external(pkg = pkg, examples = examples, document = document, run_dont_run = run_dont_run, seed = seed, mathjax = mathjax, lazy = lazy, override = override, preview = preview) 1: pkgdown::build_site(".")

jayhesselberth added a commit that referenced this issue Jun 20, 2018
Fixes parsing of Sexpr with multiple args (`\Sexpr[results=rd,stage=build]`).

Fixes #720.
@strengejacke
Copy link
Author

@strengejacke strengejacke commented Jun 20, 2018

thanks, works for me now!

@gvegayon
Copy link

@gvegayon gvegayon commented Jul 8, 2018

Same here! Thanks!

@pachadotdev
Copy link

@pachadotdev pachadotdev commented Aug 21, 2018

same here
what solved the problem for me was

library(devtools)
install_version("pkgdown", version = "1.0.0", repos = "http://cran.us.r-project.org")

@KasperSkytte
Copy link

@KasperSkytte KasperSkytte commented Aug 22, 2018

It's fixed in the latest development version. Just install it with devtools::install_github("r-lib/pkgdown"), not the one from CRAN as it is not up to date.

@aqualogy
Copy link

@aqualogy aqualogy commented Sep 13, 2018

I can confirm @KasperSkytte last comment. With current master, installed by devtools::install_github("r-lib/pkgdown") everything works well and \insertRef or \doi don't cause problems.

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

Successfully merging a pull request may close this issue.

None yet
7 participants