Skip to content

Commit

Permalink
Parse symbolic usage
Browse files Browse the repository at this point in the history
Closes #2727
  • Loading branch information
lcolladotor authored Jul 23, 2024
1 parent 2841c0f commit 6f01c92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ as_data.tag_usage <- function(x, ...) {
lines <- strsplit(text, "\n", fixed = TRUE)[[1]]
parsed <- lapply(lines, function(x) tryCatch(parse(text = x)[[1]], error = function(e) NULL))
needs_tweak <- function(x) {
is_call(x) && !is_call(x, "=") && !is_syntactic(x[[1]])
is_call(x) && !is_call(x, "=") && (is_symbol(x[[1]]) && !is_syntactic(x[[1]]))
}
to_tweak <- vapply(parsed, needs_tweak, logical(1))
lines[to_tweak] <- vapply(parsed[to_tweak], deparse1, character(1))
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ test_that("can parse dots", {
expect_equal(usage$name, "f")
})

test_that("usage2text can parse symbols (#2727)", {
expect_no_error(usage2text("viridisLite::viridis(21)"))
})

# short_name --------------------------------------------------------------

test_that("infix functions left as", {
Expand Down

0 comments on commit 6f01c92

Please sign in to comment.