Skip to content
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

Improve S3 method handling #1534

Merged
merged 12 commits into from
Nov 21, 2023
Merged

Improve S3 method handling #1534

merged 12 commits into from
Nov 21, 2023

Conversation

hadley
Copy link
Member

@hadley hadley commented Nov 16, 2023

Fixes #1175. Fixes #1451

@hadley hadley requested a review from jennybc November 16, 2023 19:30
@hadley
Copy link
Member Author

hadley commented Nov 16, 2023

@jennybc while you're welcome to take a look at the warning implementation, I'd most appreciate your feedback on the changes to the vignette

@hadley hadley changed the title Improving S3 method handling Improve S3 method handling Nov 16, 2023
Copy link
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took you up on the invitation to just focus on the vignette.

vignettes/namespace.Rmd Outdated Show resolved Hide resolved
vignettes/namespace.Rmd Outdated Show resolved Hide resolved
```{r}
#' Take an object to bizarro world
#'
#' @description
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't normally use @description explicitly. Is there a reason to do so in the current context?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I think you want the bulleted listed of methods above the fold? (i.e. we do use an explicit @description when there's a list)

vignettes/namespace.Rmd Outdated Show resolved Hide resolved

Typically, you will write methods for generics that are either defined in the current package or a package that is a hard dependency[^2] of your package.
Sometimes, however, you will want to write a method for a suggested dependency.
In this case, `@export` will not work because it assumes the generic is included or imported in your `NAMESPACE`. Instead, use `@exportS3Method`. This will use "delayed" method registration, which means the method will only be registered when the suggested package is loaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do we need to update this in R Packages 🤔 ? Scroll to the end of this section:

https://r-pkgs.org/dependencies-in-practice.html#imports-and-exports-related-to-s3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should. We'll probably also want to sunset that s3_register() method in our own packages once we can depend on 3.6. I'll file some issues so we don't forget.

hadley and others added 2 commits November 21, 2023 11:57
Co-authored-by: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
@hadley hadley merged commit 7bd492f into main Nov 21, 2023
12 checks passed
@hadley hadley deleted the missing-s3 branch November 21, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve documentation for S3 methods Should roxygen warn when S3 methods are not tagged with @export?
2 participants