Skip to content

Commit e9dfce3

Browse files
internal api should handle empty strings more grateful, yet not 100% consistent
1 parent be6449c commit e9dfce3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

R/roxygen-examples.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ style_roxygen_code_example_segment <- function(one_dont,
7070
base_indention) {
7171
if (length(one_dont) < 1L) {
7272
return(character())
73+
} else if (identical(one_dont, "\n")) {
74+
return(character(1L))
7375
}
7476
dont_seqs <- find_dont_seqs(one_dont)
7577
split_segments <- split_roxygen_segments(one_dont, unlist(dont_seqs))

R/transform-files.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,17 @@ parse_transform_serialize_r <- function(text,
270270
#' @keywords internal
271271
#' @seealso specify_transformers_drop
272272
transformers_drop <- function(text, transformers) {
273-
is_colon <- text == ";"
274-
if (any(is_colon)) {
275-
# ; can only be parsed when on the same line as other token, not the case
276-
# here since text is output of compute_parse_data_nested.
277-
text <- c(text[!is_colon], "1;")
273+
if (length(text) > 0) {
274+
is_colon <- text == ";"
275+
if (any(is_colon)) {
276+
# ; can only be parsed when on the same line as other token, not the case
277+
# here since text is output of compute_parse_data_nested.
278+
text <- c(text[!is_colon], "1;")
279+
}
280+
token <- unique(tokenize(text)$token)
281+
} else {
282+
token <- character()
278283
}
279-
token <- unique(tokenize(text)$token)
280284
for (scope in c("line_break", "space", "token", "indention")) {
281285
rules <- transformers$transformers_drop[[scope]]
282286
for (rule in names(rules)) {

0 commit comments

Comments
 (0)