Skip to content

Commit 26338cc

Browse files
committed
fix: robustify pkg_doc_codedoc_df__
1 parent 7e86c7d commit 26338cc

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

R/collect_raw.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,10 @@ extract_keyed_comment_blocks__ <- function(
483483
grepl(detect_allowed_keys_regex, x)
484484
}
485485
}
486-
is_allowed_key <- detect_allowed_keys(block_df[["key"]])
486+
487+
dbc::assert_prod_interim_is_logical_nonNA_vector(
488+
is_allowed_key <- detect_allowed_keys(block_df[["key"]])
489+
)
487490
if (insert) {
488491
# @codedoc_comment_block codedoc:::extract_keyed_comment_blocks__
489492
# @details

R/pkg_doc.R

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,26 @@ pkg_doc_codedoc_df__ <- function(
7171
)
7272
}
7373
.__PKG_DOC_ENV__.[["text_file_df"]] <- new_text_file_df
74-
pkg_nm <- read.dcf(
75-
"DESCRIPTION",
76-
fields = "Package"
77-
)[1L, 1L]
7874
extract_arg_list <- as.list(extract_arg_list)
7975
extract_arg_list[["detect_allowed_keys"]] <- function(x) {
80-
grepl(pkg_nm, x)
76+
pkg_nm <- read.dcf(
77+
"DESCRIPTION",
78+
fields = "Package"
79+
)[1L, 1L]
80+
re_set <- sprintf(
81+
c("^%s", "^news[(]\"%s", "^return[(]%s::"),
82+
pkg_nm
83+
)
84+
out <- rep(FALSE, length(x))
85+
for (re in re_set) {
86+
out <- out | grepl(re, x)
87+
}
88+
return(out)
8189
}
8290
extract_arg_list[["text_file_paths"]] <- text_file_paths
8391
.__PKG_DOC_ENV__.[["codedoc_df"]] <-
84-
do.call(codedoc::extract_keyed_comment_blocks, extract_arg_list)
92+
do.call(codedoc::extract_keyed_comment_blocks, extract_arg_list,
93+
quote = TRUE)
8594
}
8695
return(.__PKG_DOC_ENV__.[["codedoc_df"]])
8796
}
@@ -159,8 +168,7 @@ pkg_doc_fun <- function(
159168
#' otherwise.
160169
df <- pkg_doc_codedoc_df__(
161170
dir_path = getwd(),
162-
text_file_paths = text_file_paths,
163-
extract_arg_list = list(detect_allowed_keys = regex)
171+
text_file_paths = text_file_paths
164172
)
165173
# @codedoc_comment_block codedoc::pkg_doc_fun
166174
# - Collect comment block lines whose keys match one of:

0 commit comments

Comments
 (0)