forked from r-lib/roxygen2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for r-lib#1670 and r-lib#1671. Disabled resolve_link_package test
- Loading branch information
1 parent
9652d15
commit f0cdf7c
Showing
13 changed files
with
219 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: roxygen2 | ||
Title: In-Line Documentation for R | ||
Version: 7.3.2.9000 | ||
Version: 7.3.2.9001 | ||
Authors@R: c( | ||
person("Hadley", "Wickham", , "[email protected]", role = c("aut", "cre", "cph"), | ||
comment = c(ORCID = "0000-0003-4757-117X")), | ||
|
@@ -53,4 +53,4 @@ Config/testthat/parallel: TRUE | |
Encoding: UTF-8 | ||
Language: en-GB | ||
Roxygen: list(markdown = TRUE, load = "installed") | ||
RoxygenNote: 7.3.2.9000 | ||
RoxygenNote: 7.3.2.9001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
|
||
## fix 1670 ---- | ||
|
||
.expect_inherited = function(x, params) { | ||
names(params)[names(params) == "\\dots"] = "..." | ||
strings = sprintf("\\item{\\code{%s}}{%s}",names(params),params) | ||
found = stringr::str_detect(x[["..."]], stringr::fixed(strings)) | ||
expect(all(found),paste0("Params not inherited: ",paste0(names(params)[!found],collapse=","))) | ||
} | ||
|
||
test_that("inheritDotParams inherits `...` parameters from parent", { | ||
out <- roc_proc_text(rd_roclet(), " | ||
#' Foo | ||
#' | ||
#' @param x x | ||
#' @param y y | ||
#' @param \\dots foo | ||
foo <- function(x, y, ...) {} | ||
#' Bar | ||
#' | ||
#' @inheritAllDotParams foo | ||
bar <- function(...) {} | ||
")[[2]] | ||
|
||
# I expect to see here the foo dot params documented | ||
|
||
.expect_inherited( | ||
out$get_value("param"), | ||
c(x = "x", y="y", "\\dots" = "foo") | ||
) | ||
|
||
}) | ||
|
||
## fix 1671 ---- | ||
# with fix 1670 this cannot really happen any more, as for a `...` | ||
# to be passed to parent it is an error to not have a `...` | ||
# in the parent to consume unexpected parameters. In a way this | ||
# should throw an error | ||
test_that("inheritDotParams does nothing if nothing matched", { | ||
out <- roc_proc_text(rd_roclet(), " | ||
#' Foo | ||
#' | ||
#' @param x xfoo | ||
#' @param y yfoo | ||
foo <- function(x, y) {} | ||
#' Bar | ||
#' | ||
#' @param x xbar | ||
#' @param y ybar | ||
#' @inheritAllDotParams foo | ||
bar <- function(x,y,...) {} | ||
")[[2]] | ||
|
||
# I expect to see here the bar params documented | ||
|
||
expect_equal( | ||
out$get_value("param"), | ||
c(x="xbar", y="ybar") | ||
) | ||
|
||
# No inherited section and specifically no empty code block | ||
# that triggers CRAN NOTE. | ||
expect_false( | ||
any(stringr::str_detect( | ||
format(out$get_section("param")), | ||
stringr::fixed("\\item{\\code{}}{}")) | ||
) | ||
) | ||
|
||
|
||
}) | ||
|
||
|
||
test_that("inheritDotParams does nothing if dots documented", { | ||
out <- roc_proc_text(rd_roclet(), " | ||
#' Foo | ||
#' | ||
#' @param x xfoo | ||
#' @param y yfoo | ||
#' @param \\dots dotsfoo | ||
foo <- function(x, y, ...) {} | ||
#' Bar | ||
#' | ||
#' @param x xbar | ||
#' @param y ybar | ||
#' @param \\dots dotsbar | ||
#' @inheritAllDotParams foo | ||
bar <- function(x,y,...) {} | ||
")[[2]] | ||
|
||
# I expect to see here the bar params documented and no foo params | ||
|
||
expect_equal( | ||
out$get_value("param"), | ||
c(x="xbar", y="ybar", "\\dots"="dotsbar") | ||
) | ||
|
||
}) | ||
|
||
|
||
test_that("inheritAllDotParams inheritance is transmitted (mostly)", { | ||
out <- roc_proc_text(rd_roclet(), " | ||
#' Foo | ||
#' | ||
#' @param x xfoo | ||
#' @param \\dots dotsfoo | ||
foo <- function(x,...) {} | ||
#' Bar | ||
#' | ||
#' @param y ybar | ||
#' @inheritAllDotParams foo | ||
bar <- function(y,...) {} | ||
#' Baz | ||
#' | ||
#' @param z zbaz | ||
#' @inheritAllDotParams bar | ||
baz <- function(z,...) {} | ||
")[[3]] | ||
|
||
# This can be broken by placing the functions out of natural order | ||
# so that `baz` is defined before `bar`. | ||
|
||
|
||
expect_equal( | ||
out$get_value("param")[1], | ||
c(z="zbaz") | ||
) | ||
|
||
.expect_inherited( | ||
out$get_value("param"), | ||
c(x="xfoo", y="ybar", "\\dots"="dotsfoo") | ||
) | ||
|
||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ Author: Hadley <[email protected]> | |
Maintainer: Hadley <[email protected]> | ||
Encoding: UTF-8 | ||
Version: 0.1 | ||
RoxygenNote: 7.3.2.9000 | ||
RoxygenNote: 7.3.2.9001 |
Oops, something went wrong.