Skip to content

Commit

Permalink
improve 'check_block_title' fn to apply to all tags for #41
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Aug 27, 2024
1 parent 46942f4 commit 4537f11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: srr
Title: 'rOpenSci' Review Roclets
Version: 0.1.3.006
Version: 0.1.3.007
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
21 changes: 9 additions & 12 deletions R/roclet.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,18 @@ check_block_title <- function (block, tag) {

block_title <- roxygen2::block_get_tag_value (block, "title")
block_title <- ifelse (is.null (block_title), "", block_title)
if (grepl ("^NA\\_st", block_title)) {
if (tag != "srrstatsNA" && grepl ("^NA\\_st", block_title)) {
stop (paste0 (
"An NA_standards block should only contain ",
"'@srrstatsNA' tags, and no '@",
tag, "' tags."
))
} else if (tag == "srrstatsNA" & !block_title == "NA_standards") {
stop (
"@srrstatsNA tags should only appear in ",
"a block with a title of NA_standards"
)
}

}

#' process_srrstats_tags
Expand All @@ -220,10 +224,10 @@ check_block_title <- function (block, tag) {
#' @noRd
process_srrstats_tags <- function (block, fn_name = TRUE, dir = "R") {

func_name <- block$object$alias

check_block_title (block, "srrstats")

func_name <- block$object$alias

standards <- roxygen2::block_get_tags (block, "srrstats")
standards <- unlist (lapply (standards, function (i) i$val))

Expand Down Expand Up @@ -264,14 +268,7 @@ process_srrstats_tags <- function (block, fn_name = TRUE, dir = "R") {
#' @noRd
process_srrstatsNA_tags <- function (block, fn_name = TRUE, dir = "R") { # nolint

block_title <- roxygen2::block_get_tag_value (block, "title")
block_title <- ifelse (length (block_title) == 0L, "", block_title)
if (!block_title == "NA_standards") {
stop (
"@srrstatsNA tags should only appear in ",
"a block with a title of NA_standards"
)
}
check_block_title (block, "srrstatsNA")

standards <- roxygen2::block_get_tags (block, "srrstatsNA")
standards <- unlist (lapply (standards, function (i) i$val))
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/srr",
"issueTracker": "https://github.com/ropensci-review-tools/srr/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.3.006",
"version": "0.1.3.007",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 4537f11

Please sign in to comment.