-
Notifications
You must be signed in to change notification settings - Fork 22
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
Check 'repos' repositories and CRAN for URL if package isn't installed #108
Conversation
…tter reflect what's being done
…kage (we're using BMRSr but this could change to a more robust way of looking for a package with a URL)
…ou'll strip out any repo that isn't named
…stom repo but the package wasn't present on it
… can have something like mycran)
…_db() function is available
Because of the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Comments below.
When getting a URL from CRAN or a custom repo using the `url_from_cran()` or `url_from_custom_repo()` functions respectively, you'll always get the result passed from `parse_urls()`. And now `parse_urls()` can handle empty values, the return value is the same for empty character string and NA values - both of which could be returned from the dataframe check depending on whether the package and/or URL is found.
One thing I wanted to get your thoughts on @hadley is the time penalty associated with checking CRAN every time
We're looking at about 4 seconds for packages from a custom repo and about 6 seconds for package from CRAN. I don't imagine that there will actually be that many packages that will get this far (i.e. I think most of them will be installed), but I think it's still a consideration. What do you think? |
Following the introduction of the memoise package, the benchmarks are looking a lot more healthy:
The first run is taking us about 3 seconds but then everything after that is basically instantaneous. |
…ing else (named or unnamed)
…if a URL cannot be found. Previously, downlit would always default to "https://rdrr.io" when a custom URL for the package couldn't be found. Now you can register a new function via `register_default_package_ref()` to be used.
I've also had a go at adding the ability to register a custom function that will be used when no URL can be found for the package (on CRAN or otherwise). It's a first attempt to any comments/improvements are welcome 👍 |
… everything else (named or unnamed)" This reverts commit 2fdad50.
I've reverted the custom function registration out because I think that belongs in a separate PR, and I can merge your earlier work without more discussion. |
@ARawles I've tweaked your code quite a bit, but I figured out how to add a test with a custom repo, so I'm fairly confident that I haven't broken anything. If you want to have a go at the custom function in another PR, you should be able to cherry-pick the commits of of this branch; LMK if you need any hints on how to do that. |
This PR fixes #106.
Previously, packages needed to be installed for downlit to find the URL field. With this PR, downlit will go through 3 stages to try and find the URL, only proceeding to the next one if the previous one was unsuccessful:
tools::CRAN_package_db()
function, which includes more meta-data than theutils::available.packages()
function.A test case has been written to check that URLS for packages that are not installed are found correctly, however it currently relies on the
BMRSr
package not being installed. Although it's unlikely that this package would ever be installed when these tests are being run as part of a CI process, it's not perfect.Still left to consider is the possibility of allowing the user to register a custom function that could be used to find a PACKAGE url (see Issue for discussion).