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

Support @exportS3Method NULL #1551

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* The NAMESPACE roclet now reports if you have S3 methods that are missing
an `@export` tag. All S3 methods need to be `@export`ed (which confusingly
really registers the method) even if the generic is not. This avoids rare,
but hard to debug, problems (#1175).
but hard to debug, problems (#1175). You can suppress the warning with
`@exportS3Method NULL` (#1550).

* `@include` now gives an informative warning if you use a path that doesn't
exist (#1497).
Expand Down
4 changes: 4 additions & 0 deletions R/namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ roxy_tag_parse.roxy_tag_exportS3Method <- function(x) {
roxy_tag_ns.roxy_tag_exportS3Method <- function(x, block, env) {
obj <- block$object

if (identical(x$val, "NULL")) {
return()
}

if (identical(x$val, "")) {
if (!inherits(obj, "s3method")) {
warn_roxy_tag(x, "must be used with an known S3 method")
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@ test_that("warns if S3 method not documented", {
)
})


test_that("can suppress the warning", {
block <- "
#' @exportS3Method NULL
mean.myclass <- function(x) 1
"
expect_silent(out <- roc_proc_text(namespace_roclet(), block))
expect_equal(out, character())
})


test_that("doesn't warn for potential false postives", {
roc <- namespace_roclet()
expect_no_warning({
Expand Down
2 changes: 2 additions & 0 deletions vignettes/namespace.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ bizarro.character <- function(x, ...) {
}
```

If you are exporting a method in some other way, you can use `@exportS3Method NULL` to suppress the warning.

You have four options for documenting an S3 method:

- Don't document it; it's not required, and not needed for simple generics where the user won't care about the details.
Expand Down
Loading