-
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.
Add matching of
select
to formal arguments of the function to cite …
…when `type = "param"` or `type = "dot_params"`. Also conform multiple aspects of the package for the compliance of CRAN submission.
- Loading branch information
Showing
10 changed files
with
148 additions
and
26 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
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
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,21 +1,37 @@ | ||
# Inherit a standard section, and leave the first letter as is | ||
cat(extract_roc_text(stats::lm, type = "general", select = "description", capitalize = NA)) | ||
cat( | ||
extract_roc_text(stats::lm, | ||
type = "general", | ||
select = "description", | ||
capitalize = NA) | ||
) | ||
|
||
# Inherit a self-defined section, and capitalize the first letter | ||
cat(extract_roc_text(stats::lm, type = "section", select = "Using time series", capitalize = TRUE)) | ||
cat( | ||
extract_roc_text(stats::lm, | ||
type = "section", | ||
select = "Using time series", | ||
capitalize = TRUE) | ||
) | ||
|
||
# Inherit a parameter, and diffuse it into text | ||
cat( | ||
paste0( | ||
"Here is the `formula` argument of `stats::lm`, defined as: ", | ||
extract_roc_text(stats::lm, type = "param", select = "formula", capitalize = FALSE) | ||
extract_roc_text(stats::lm, | ||
type = "param", | ||
select = "formula", | ||
capitalize = FALSE) | ||
) | ||
) | ||
|
||
# Inherit a set of dot params, and diffuse it into text | ||
cat( | ||
paste0( | ||
"`lm_arg` is a named list of ", | ||
extract_roc_text(stats::lm, type = "dot_params", select = c("-formula", "-data"), capitalize = FALSE) | ||
extract_roc_text(stats::lm, | ||
type = "dot_params", | ||
select = c("-formula", "-data"), | ||
capitalize = FALSE) | ||
) | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
library(testthat) | ||
library(stringr) | ||
|
||
test_that("extract_roc_text extracts parts of a function documentation", { | ||
expect_match(extract_roc_text(stats::lm, "general", "title", NA), | ||
"^Fitting Linear Models$") | ||
expect_match(extract_roc_text(stats::lm, "general", "description", NA), | ||
"^\\\\code\\{lm\\} is used to fit linear models\\.") | ||
expect_match(extract_roc_text(stats::lm, "general", "return", NA), | ||
"^\\\\code\\{lm\\} returns an object of") | ||
expect_match(extract_roc_text(stats::lm, "general", "author", NA), | ||
"^The design was inspired by") | ||
expect_match(extract_roc_text(stats::lm, "general", "references", NA), | ||
"^Chambers, J\\. M\\. \\(1992\\)") | ||
expect_match(extract_roc_text(stats::lm, "general", "examples", NA), | ||
"^require\\(graphics\\)") | ||
expect_match(extract_roc_text(stats::lm, "section", "Using time series", NA), | ||
"^Considerable care is needed when using") | ||
expect_match(extract_roc_text(stats::lm, "param", "formula", NA), | ||
"^an object of class") | ||
expect_match(extract_roc_text(stats::lm, "dot_params", "formula data", NA), | ||
"^Arguments passed on to") | ||
expect_match(extract_roc_text(stats::lm, "dot_params", c("-formula", "-data"), NA), | ||
"^Arguments passed on to") | ||
}) | ||
|
||
test_that("extract_roc_text sets capitalization", { | ||
expect_match(extract_roc_text(stats::lm, "general", "title", TRUE), | ||
"^Fitting Linear Models$") | ||
expect_match(extract_roc_text(stats::lm, "general", "title", FALSE), | ||
"^fitting Linear Models$") | ||
# Capitalization should not work on non-letter characters, e.g. \\ | ||
expect_match(extract_roc_text(stats::lm, "general", "description", TRUE), | ||
"^\\\\code\\{lm\\} is used to fit linear models\\.") | ||
expect_match(extract_roc_text(stats::lm, "general", "description", TRUE), | ||
"^\\\\code\\{lm\\} is used to fit linear models\\.") | ||
}) |
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,16 @@ | ||
library(testthat) | ||
library(stringr) | ||
|
||
fun_text <- ' | ||
#\' \\code{iris} is a `r nrow(iris)`-row matrix. | ||
#\' | ||
#\' \\code{iris} matrix has | ||
#\' ```{r results="hold"} | ||
#\' ncol(iris) | ||
#\' ``` | ||
#\' columns. | ||
print_iris <- function() iris | ||
' | ||
test_that("roc_eval_text parses diffused roxygen comments to Rd text", { | ||
expect_true(roc_eval_text(roxygen2::rd_roclet(), fun_text)[[1L]]$is_valid()) | ||
}) |