File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ check <- function(
8282 }
8383 error_on <- match.arg(error_on )
8484
85- document <- document %|| % can_document(pkg )
85+ document <- document %|| % can_document(pkg $ roxygennote )
8686 if (document ) {
8787 if (! quiet ) {
8888 cat_rule(" Documenting" , col = " cyan" , line = 2 )
@@ -133,19 +133,17 @@ check <- function(
133133 )
134134}
135135
136- can_document <- function (pkg ) {
137- required <- pkg $ roxygennote
136+ can_document <- function (required , installed = packageVersion(" roxygen2" )) {
138137 if (is.null(required )) {
139- # Doesn't use roxygen2 at all
140138 return (FALSE )
141139 }
142140
143- installed <- packageVersion(" roxygen2" )
144141 if (required != installed ) {
145142 cli :: cat_rule(" Documenting" , col = " red" , line = 2 )
146143 cli :: cli_inform(c(
147- i = " Installed roxygen2 version ({installed}) doesn't match required ({required})" ,
148- x = " {.fun check} will not re-document this package"
144+ i = " Installed roxygen2 version ({installed}) doesn't match declared ({required})" ,
145+ x = " {.fun check} will not re-document this package." ,
146+ i = " Do you need to re-run {.fun document}?"
149147 ))
150148 FALSE
151149 } else {
Original file line number Diff line number Diff line change 1+ # can determine when to document
2+
3+ Code
4+ result <- can_document("1.0.0", installed = "2.0.0")
5+ Output
6+ == Documenting =================================================================
7+ Message
8+ i Installed roxygen2 version (2.0.0) doesn't match declared (1.0.0)
9+ x `check()` will not re-document this package.
10+ i Do you need to re-run `document()`?
11+
Original file line number Diff line number Diff line change 11test_that(" can determine when to document" , {
2- expect_false(can_document(list ()))
3- # TODO: switch to expect_snapshot()
4- expect_output(
5- expect_message(
6- expect_false(can_document(list (roxygennote = " 15.0.00" ))),
7- " doesn't match required"
8- )
9- )
10- expect_true(can_document(list (roxygennote = packageVersion(" roxygen2" ))))
2+ expect_false(can_document(NULL ))
3+ expect_true(can_document(" 1.0.0" , installed = " 1.0.0" ))
4+ expect_snapshot(result <- can_document(" 1.0.0" , installed = " 2.0.0" ))
5+ expect_false(result )
116})
127
138test_that(" fail instead of sending an email to wrong recipient" , {
You can’t perform that action at this time.
0 commit comments