pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Vignette source links are built incorrectly when current wd is not package directory

Open idmn opened this issue 3 years ago • 0 comments

Vignette source links are generated in this line https://github.com/r-lib/pkgdown/blob/main/R/build-articles.R#L242 input is one of the paths in pkg$vignettes$file_in and this path is always relative to the package root. So it seems wrong to use fs::path_rel() here because it treats this path as relative to the current working directory. Maybe just

source = repo_source(pkg, input)

would work fine?

At the same time source links for function documentation are built correctly regardless of the wd.

Reprex:

setwd("~/projects/open_source/pkgdown/")
pkg <- pkgdown::as_pkgdown()

pkg$vignettes$file_in[1]
#> vignettes/customise.Rmd
pkg$src_path
#> /Users/iaroslav/projects/open_source/pkgdown

fs::path_rel(pkg$vignettes$file_in[1], pkg$src_path)
#> vignettes/customise.Rmd

setwd("..")
pkg <- pkgdown::as_pkgdown("pkgdown/")
pkg$vignettes$file_in[1]
#> vignettes/customise.Rmd
pkg$src_path
#> /Users/iaroslav/projects/open_source/pkgdown

fs::path_rel(pkg$vignettes$file_in[1], pkg$src_path)
#> ../vignettes/customise.Rmd

Created on 2022-07-27 by the reprex package (v2.0.1)

idmn avatar Jul 27 '22 15:07 idmn