-
Notifications
You must be signed in to change notification settings - Fork 14
feat: simplify use of vcr in examples #548
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
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,7 @@ | |||
| #' @rdname vcr-example | |||
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.
I'd like to add an actual test but am not sure how to.
| #' @return Nothing: called for file system side effects. | ||
| #' @export | ||
| #' | ||
| use_vcr_examples <- function(path = ".") { |
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.
d000d4f to
905fcf3
Compare
d4bce45 to
ab67422
Compare
| @@ -1,8 +1,12 @@ | |||
| #' Use cassettes in examples | |||
| #' | |||
| #' @description | |||
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.
In this file it'd be useful to describe how to run the examples. devtools::run_examples()? Use example()? Run the code by opening the Rd file? Which reminds me of posit-dev/positron#1734
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.
Yes! I ended up running my examples line by line, which was a little tedious.
| } | ||
|
|
||
| #' @export | ||
| roxy_tag_rd.roxy_tag_examplesVCR <- function(x, base_path, env) { |
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.
I looked at https://github.com/r-lib/roxygen2/pull/993/files
|
I wonder how useful this would actually be, given that there might be other boilerplate code anyway: in ellmer an option is set and unset, in @drmowinckels' package a function is called to fake authentication. Could one somehow use Could one also store some boilerplate for all examples in a central place, like a general setup chunk for all examples, that could set local options for instance? I might be overthinking this. 😅 |
R/roxygen.R
Outdated
| #' @importFrom roxygen2 roxy_tag_parse | ||
| #' @importFrom roxygen2 roxy_tag_rd |
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.
I think you could drop these and switch from @exporting the method to @S3method registering it so you don't need to import roxygen2.
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.
Sorry, I meant @exportS3Method, https://roxygen2.r-lib.org/articles/namespace.html#s3
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.
I made a new try, I hope I got it right. Thanks for the link!
|
Thanks @maelle !! I imagine users won't want to write their own How fragile do you think these code changes are in this PR? That is, adding it here means we need to maintain it moving forward, and I'm curious if these kinds of additions to roxygen2 get broken with new roxygen2 versions? Asking because I'm not familiar with roxygen2 from the dev side. So what is the usage flow like? Someone adds the |
Maybe they would, if that were better documented/easier? But yes, not vcr's concern.
Well with @hadley as a reviewer hopefully we're adding the tag correctly so that it won't be fragile. 😅 There are other packages out there building upon roxygen2's infrastructure, like @mpadge's srr https://github.com/ropensci-review-tools/srr (which is far more complex than what we're doing in this PR!).
Instead of using |
|
@maelle it's so sweet and naive that you think I have any idea how adding new roxygen2 tags works 😆 |
|
I simply expect you as a roxygen2 maintainer to not break this precious tag in the future 🥺 |
|
This is cool people! Just one note that from all attempts at Lines 8 to 25 in 35f3a67
into roclet_process instead. That code is quite clearly processing and not parsing,
One day somebody here will get around to writing the long-awaiting roxygen2 extension manual, and when that happens, it should and will definitely suggest that parsing is strictly for parsing only, and processing is for everything else. Moreover, processing is also general, and can be applied directly to all tags associated with a given roclet, while parsing is applied to the specified tag only. Any future generalisation to other |
|
Sort of related: r-lib/roxygen2#1697 where I had asked "could one define a whole new tag in a package without importing roxygen2?" 😅 |
|
@mpadge I'm sorry but I didn't understand. I thought you meant moving the body of Any chance you could do a PR to this PR? 😅 Thanks in advance. |
|
@maelle What's the next step in this PR? |
I'm also still wondering how we could help with more complicated setup code for examples #548 (comment) but that might be beyond the scope of both this PR and vcr. 😸 |
I did a detailed comparison of this PR with
PR #551 hopefully helps. It adds a modified version of the pkg skeleton used to test |
|
thanks @mpadge ! Sorry for delay on this, i'll take a look at the PR |
Fix #546
Example usage: EMODnet/emodnet.wfs#193