Skip to content

Commit

Permalink
fixed usage section for infix functions containing <- (#569)
Browse files Browse the repository at this point in the history
* fixed usage for infix with <-; fixes #554

* added NEWS bullet for #554
  • Loading branch information
Nate Teetor authored and hadley committed Jan 30, 2017
1 parent e77aa01 commit 6c26d86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
* Roxygen now parses nonASCII documentation correctly (as long as UTF-8
encoded or specified Encoding in DESCRIPTION) (#532, @shrektan),
and ignores files listed in `.Rbuildignore` (#446, @fmichonneau).

* Automatically generating a usage section for an infix function containing "<-"
no longer removes "<-" from the function name (#554).

## Extending roxygen2

Expand Down
2 changes: 1 addition & 1 deletion R/object-usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object_usage.rcclass <- function(x) NULL

function_usage <- function(name, formals, format_name = identity) {
arglist <- args_string(usage_args(formals))
if (is_replacement_fun(name)) {
if (is_replacement_fun(name) && !is_infix_fun(name)) {
name <- str_replace(name, fixed("<-"), "")
formals$value <- NULL

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-rd-usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ test_that("default usage correct for infix functions", {
expect_equal(get_tag(out, "usage")$values, rd("a \\%.\\% b"))
})

test_that("default usage correct of infix functions containing \"<-\"", {
out <- roc_proc_text(rd_roclet(), "
#' Infix fun containing <-
'%<-%' <- function(a, b) 1")[[1]]

expect_equal(get_tag(out, "usage")$values, rd("a \\%<-\\% b"))
})

test_that("default usage correct for S3 methods", {
out <- roc_proc_text(rd_roclet(), "
#' Regular
Expand Down

0 comments on commit 6c26d86

Please sign in to comment.