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

FIX @exportS3method -> @exportS3Method #1590

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

* `@author`s are de-duplicated in merged documentation (@DanChaltiel, #1333).

* `@exportS3method pkg::generic` now works when `pkg::generic` isn't
* `@exportS3Method pkg::generic` now works when `pkg::generic` isn't
imported by your package (#1085).

* `@includeRmd` is now adapted to change in rmarkdown 2.12 regarding math
Expand Down
4 changes: 2 additions & 2 deletions R/namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ warn_missing_s3_exports <- function(blocks, env) {
funs <- Filter(is.function, objs)
methods <- funs[map_lgl(names(funs), is_s3_method, env = env)]

s3blocks <- blocks[map_lgl(blocks, block_has_tags, c("export", "exportS3method"))]
s3blocks <- blocks[map_lgl(blocks, block_has_tags, c("export", "exportS3Method"))]
s3objects <- map(blocks, function(block) block$object$value)

undocumented <- methods[!methods %in% s3objects]
Expand All @@ -405,7 +405,7 @@ warn_missing_s3_exports <- function(blocks, env) {
map2(undocumented, names(undocumented), function(fun, name) {
warn_roxy_function(
fun,
"S3 method {.arg {name}} needs @export or @exportS3method tag"
"S3 method {.arg {name}} needs @export or @exportS3Method tag"
)
})
}
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/namespace.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @exportS3method generates fully automatically
# @exportS3Method generates fully automatically

Code
. <- roc_proc_text(namespace_roclet(), block)
Message
x <text>:2: @exportS3Method must be used with an known S3 method.

# @exportS3method can extract class from generic
# @exportS3Method can extract class from generic

Code
. <- roc_proc_text(namespace_roclet(), block)
Expand Down Expand Up @@ -97,13 +97,13 @@
Code
. <- roc_proc_text(namespace_roclet(), block)
Message
x <text>:5: S3 method `mean.myclass` needs @export or @exportS3method tag.
x <text>:3: S3 method `foo.numeric` needs @export or @exportS3method tag.
x <text>:5: S3 method `mean.myclass` needs @export or @exportS3Method tag.
x <text>:3: S3 method `foo.numeric` needs @export or @exportS3Method tag.

---

Code
. <- roc_proc_text(namespace_roclet(), block)
Message
x <text>:3: S3 method `foo.{` needs @export or @exportS3method tag.
x <text>:3: S3 method `foo.{` needs @export or @exportS3Method tag.

6 changes: 3 additions & 3 deletions tests/testthat/test-namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test_that("export handles non-syntactic names", {
expect_equal(out, "S3method(\"foo-bar\",integer)")
})

test_that("@exportS3method generates fully automatically", {
test_that("@exportS3Method generates fully automatically", {
out <- roc_proc_text(namespace_roclet(),"
#' @exportS3Method
mean.foo <- function(x) 'foo'
Expand All @@ -100,15 +100,15 @@ test_that("@exportS3method generates fully automatically", {
expect_snapshot(. <- roc_proc_text(namespace_roclet(), block))
})

test_that("@exportS3methd can create literal directive", {
test_that("@exportS3Method can create literal directive", {
out <- roc_proc_text(namespace_roclet(),
"#' @exportS3Method base::mean foo
NULL
")
expect_equal(out, "S3method(base::mean,foo)")
})

test_that("@exportS3method can extract class from generic", {
test_that("@exportS3Method can extract class from generic", {
out <- roc_proc_text(namespace_roclet(), "
#' @exportS3Method pkg::foo
foo.bar <- function(x) 'foo'
Expand Down
2 changes: 1 addition & 1 deletion vignettes/namespace.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This is a little frustrating at first, but soon becomes second-nature.
## Exports

In order for your users to use a function[^1] in your package, you must **export** it.
In most cases, you can just use the `@export` tag, and roxygen2 will automatically figure out which `NAMESPACE` directive (i.e. `export()`, `exportS3method()`, `exportClasses()`, or`exportMethods()`) you need.
In most cases, you can just use the `@export` tag, and roxygen2 will automatically figure out which `NAMESPACE` directive (i.e. `export()`, `S3method()`, `exportClasses()`, or`exportMethods()`) you need.

[^1]: Including S3 and S4 generics and methods.

Expand Down
Loading