Skip to content

Commit

Permalink
Use parse in @inheritParams. Closes #236
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 11, 2014
1 parent 9af1616 commit 753d748
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Expand Up @@ -63,6 +63,9 @@ Roxygen2 4.0.0 is a major update to roxygen2 that makes provides enhanced error

## Bug fixes and minor improvements

* Better parsing of non-syntactic function names in other packages when
used in `@inheritParams` (#236).

* Deprecated arguments to `roxygenise()` (`roxygen.dir`, `copy.package`,
`overwrite`, `unlink.target`) removed.

Expand Down
6 changes: 4 additions & 2 deletions R/inherit-params.R
Expand Up @@ -37,9 +37,11 @@ find_params <- function(inheritor, topics, name_lookup) {

if (has_colons) {
# Reference to another package
pieces <- strsplit(inheritor, "::", fixed = TRUE)[[1]]
params <- rd_arguments(get_rd(pieces[2], pieces[1]))
parsed <- parse(text = inheritor)[[1]]
pkg <- as.character(parsed[[2]])
fun <- as.character(parsed[[3]])

params <- rd_arguments(get_rd(fun, pkg))
} else {
# Reference within this package
rd_name <- names(Filter(function(x) inheritor %in% x, name_lookup))
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-param.R
Expand Up @@ -93,3 +93,8 @@ test_that("data objects don't get params", {
expect_equal(get_tag(out, "param"), NULL)

})

test_that("find_params parses input", {
params <- find_params("utils::`?`", NULL, NULL)
expect_equal(names(params), c("topic", "type"))
})

0 comments on commit 753d748

Please sign in to comment.