From 4537f115d1ed36ef1b46d3d1230fa3a85e8100bd Mon Sep 17 00:00:00 2001 From: mpadge Date: Tue, 27 Aug 2024 10:13:10 +0200 Subject: [PATCH] improve 'check_block_title' fn to apply to all tags for #41 --- DESCRIPTION | 2 +- R/roclet.R | 21 +++++++++------------ codemeta.json | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 45e6cff..df0e1e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", , "mark@ropensci.org", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2172-5265")) diff --git a/R/roclet.R b/R/roclet.R index 59a491a..24ff370 100644 --- a/R/roclet.R +++ b/R/roclet.R @@ -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 @@ -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)) @@ -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)) diff --git a/codemeta.json b/codemeta.json index 6eacb00..8abaec2 100644 --- a/codemeta.json +++ b/codemeta.json @@ -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",