Skip to content

Commit 2915a80

Browse files
committed
feat: add encoding = UTF-8 to arg readLines_arg_list default
1 parent 8a4c73f commit 2915a80

File tree

5 files changed

+49
-18
lines changed

5 files changed

+49
-18
lines changed

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<!-- generated by R package codedoc; do not modify! -->
22

3+
## News for version 0.11.0
4+
5+
### codedoc::extract_keyed_comment_blocks
6+
7+
`codedoc::extract_keyed_comment_blocks` argument `readLines_arg_list` is now
8+
by default `NULL` which implies `list(warn = FALSE, encoding = "UTF-8")`.
9+
10+
311
## News for version 0.10.5
412

513
### codedoc::pkg_doc_obj

R/codedoc_lines.R

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@ codedoc_lines <- function(
2424
# @codedoc_comment_block news("codedoc::codedoc_lines", "2022-02-17", "0.2.15")
2525
# New exported function `[codedoc::codedoc_lines]`.
2626
# @codedoc_comment_block news("codedoc::codedoc_lines", "2022-02-17", "0.2.15")
27-
dbc::assert_is_one_of(
28-
extract_arg_list,
29-
funs = list(
30-
dbc::report_is_NULL,
31-
dbc::report_is_list
32-
),
33-
assertion_type = assertion_type
27+
stopifnot(
28+
inherits(extract_arg_list, c("NULL", "list"))
3429
)
3530
assert_arg_text_file_paths(text_file_paths, assertion_type = assertion_type)
3631
extract_arg_list <- as.list(extract_arg_list)

R/collect_raw.R

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ detect_codedoc_key_lines <- function(x) {
1515
#' @title Read codedoc-formatted Code Comments
1616
#' @description
1717
#' Extracts blocks of specifically formatted comments from text file.
18-
#' @param readLines_arg_list `[list]`
19-
#' (optional, default `list(warn = FALSE)`)
18+
#' @param readLines_arg_list `[NULL, list]`
19+
#' (optional, default `NULL`)
2020
#'
2121
#' list of arguments passed to [readLines]; `con` is always set to
22-
#' an element of `text_file_paths`
22+
#' an element of `text_file_paths`.
23+
#'
24+
#' - `NULL`: Use `list(warn = FALSE, encoding = "UTF-8")`.
25+
#' - `list`: use these arguments. E.g. `list(encoding = "my_weird_encoding")`
2326
#' @param string_interpolation_eval_env `[environment]`
2427
#' (optional, default `parent.frame(1L)`)
2528
#'
@@ -125,8 +128,13 @@ extract_keyed_comment_blocks_assertions__ <- function(
125128

126129
dbc::assert_is_environment(string_interpolation_eval_env, call = call,
127130
assertion_type = assertion_type)
128-
dbc::assert_is_list(readLines_arg_list, call = call,
129-
assertion_type = assertion_type)
131+
dbc::assert_is_one_of(
132+
readLines_arg_list,
133+
funs = list(dbc::report_is_NULL,
134+
dbc::report_is_list),
135+
call = call,
136+
assertion_type = assertion_type
137+
)
130138
}
131139

132140
#' @template arg_assertion_type
@@ -138,7 +146,7 @@ extract_keyed_comment_blocks <- function(
138146
clean_comment_lines = NULL,
139147
detect_allowed_keys = "",
140148
sort_by = NULL,
141-
readLines_arg_list = list(warn = FALSE),
149+
readLines_arg_list = NULL,
142150
string_interpolation_eval_env = parent.frame(1L),
143151
detect_allowed_keys_grepl_arg_list = NULL,
144152
assertion_type = "input"
@@ -321,7 +329,7 @@ extract_keyed_comment_blocks__ <- function(
321329
clean_comment_lines = NULL,
322330
detect_allowed_keys = "",
323331
sort_by = NULL,
324-
readLines_arg_list = list(warn = FALSE),
332+
readLines_arg_list = NULL,
325333
string_interpolation_eval_env = parent.frame(1L),
326334
insert = TRUE,
327335
interpolate = TRUE,
@@ -341,6 +349,13 @@ extract_keyed_comment_blocks__ <- function(
341349
assertion_type = assertion_type,
342350
call = main_call
343351
)
352+
# @codedoc_comment_block news("codedoc::extract_keyed_comment_blocks", "2026-03-11", "0.11.0")
353+
# `codedoc::extract_keyed_comment_blocks` argument `readLines_arg_list` is now
354+
# by default `NULL` which implies `list(warn = FALSE, encoding = "UTF-8")`.
355+
# @codedoc_comment_block news("codedoc::extract_keyed_comment_blocks", "2026-03-11", "0.11.0")
356+
if (is.null(readLines_arg_list)) {
357+
readLines_arg_list <- list(warn = FALSE, encoding = "UTF-8")
358+
}
344359

345360
if (is.null(text_file_paths)) {
346361
# @codedoc_comment_block codedoc:::extract_keyed_comment_blocks__

man/codedoc-package.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/extract_keyed_comment_blocks.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)