r-lib / urlchecker

Run CRAN URL checks from older versions of R
https://urlchecker.r-lib.org/
GNU General Public License v3.0
45 stars 5 forks source link

run url_check() with_pandoc_available() #11

Closed dpprdan closed 3 years ago

dpprdan commented 3 years ago

This adds a function with_pandoc_available() and runs url_check() with it. Closes #10.

with_pandoc_available() is slightly different from with_pandoc_path(). It first checks whether pandoc is on the PATH and only puts RStudio's pandoc on the PATH if it is not (assuming that users prefer to have the pandoc on the path that they deliberately installed over RStudio's). If neither is available, with_pandoc_available() throws an error.

with_pandoc_available() is then applied to url_db_from_package_sources() in url_check() (in order to fail early if pandoc is not available).

Side note: I don't quite understand the if(requireNamespace("xml2", quietly = TRUE)): https://github.com/r-lib/urlchecker/blob/65a2f317cff003cff77b8c908091d0b4be283fed/R/urltools.R#L286 https://github.com/r-lib/urlchecker/blob/65a2f317cff003cff77b8c908091d0b4be283fed/R/urltools.R#L315 Can't this be ommitted? xml2 is in Imports, so it has to be available. If it wasn't, not all potential URL locations would be checked.

jimhester commented 3 years ago

Most of the code in this package comes from the tools package and was deliberately not changed significantly except where needed to use from an R package. That is where the requireNamespace() calls are from and I would prefer to keep them.

dpprdan commented 3 years ago

Re: file.sep: Could it potentially be a problem that pandoc_path contains / and all paths in sys_path contain \\? (On Windows, obviously).

dpprdan commented 3 years ago

Most of the code in this package comes from the tools package

Apropos: IIUC there have been 4 commits to tools' urltools.R since you forked the code, one of which a patch from you. Should https://github.com/r-lib/urlchecker/blob/master/R/urltools.R be kept in sync with https://github.com/wch/r-source/blob/trunk/src/library/tools/R/urltools.R?

jimhester commented 3 years ago

Thanks!