diff --git a/R/usage.R b/R/usage.R index 1c4631fa0..6ecc78e71 100644 --- a/R/usage.R +++ b/R/usage.R @@ -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)) diff --git a/tests/testthat/test-usage.R b/tests/testthat/test-usage.R index 776f7df50..97a00b83a 100644 --- a/tests/testthat/test-usage.R +++ b/tests/testthat/test-usage.R @@ -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", {