r-lib / downlit

Syntax Highlighting and Automatic Linking
https://downlit.r-lib.org
Other
90 stars 22 forks source link

Feature: Link to bioconductor vignettes #145

Closed zeehio closed 2 years ago

zeehio commented 2 years ago

This merge request provides support to parse vignette(...) calls that call vignettes from Bioconductor packages.

With the latest CRAN release version, a link is formed that returns a 404 error:

downlit::autolink('vignette("Introduction_To_BiocParallel", package = "BiocParallel")')
# [1] "<a href='https://cran.rstudio.com/web/packages/BiocParallel/vignettes/Introduction_To_BiocParallel.pdf'>vignette(\"Introduction_To_BiocParallel\", package = \"BiocParallel\")</a>"

With this pull request, we get the correct link:

downlit::autolink('vignette("Introduction_To_BiocParallel", package = "BiocParallel")')
# [1] "<a href='https://bioconductor.org/packages/release/bioc/vignettes/BiocParallel/inst/doc/Introduction_To_BiocParallel.pdf'>vignette(\"Introduction_To_BiocParallel\", package = \"BiocParallel\")</a>"

I went through a rabbit hole the last afternoon starting from pkgdown until I got here, I hope I can help get this fixed.

hadley commented 2 years ago

Is there possibly an easier way to detect if a package is from BioConductor by inspecting packageDescription()?

zeehio commented 2 years ago

Oh yes, I did not realize that to get the path to the vignette we already required the package to be installed.

This simplifies a lot the code. Thanks!

I suggest to squash the commits when merging into main.

hadley commented 2 years ago

Thanks!