Skip to content

Commit 0e0619d

Browse files
Merge branch 'main' into bump-to-r36
2 parents 2100033 + e5ecef7 commit 0e0619d

37 files changed

+640
-594
lines changed

R/nest.R

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -327,33 +327,35 @@ set_spaces <- function(spaces_after_prefix, force_one) {
327327
#' @return A nested parse table.
328328
#' @keywords internal
329329
nest_parse_data <- function(pd_flat) {
330-
if (all(pd_flat$parent <= 0L)) {
331-
return(pd_flat)
330+
repeat {
331+
if (all(pd_flat$parent <= 0L)) {
332+
return(pd_flat)
333+
}
334+
pd_flat$internal <- with(pd_flat, (id %in% parent) | (parent <= 0L))
335+
split_data <- split(pd_flat, pd_flat$internal)
336+
337+
child <- split_data$`FALSE`
338+
internal <- split_data$`TRUE`
339+
340+
internal$internal_child <- internal$child
341+
internal$child <- NULL
342+
343+
child$parent_ <- child$parent
344+
345+
rhs <- nest_(child, "child", setdiff(names(child), "parent_"))
346+
347+
nested <- left_join(internal, rhs, by = c("id" = "parent_"))
348+
349+
children <- nested$child
350+
for (i in seq_along(children)) {
351+
new <- combine_children(children[[i]], nested$internal_child[[i]])
352+
# Work around is.null(new)
353+
children[i] <- list(new)
354+
}
355+
nested$child <- children
356+
nested$internal_child <- NULL
357+
pd_flat <- nested
332358
}
333-
pd_flat$internal <- with(pd_flat, (id %in% parent) | (parent <= 0L))
334-
split_data <- split(pd_flat, pd_flat$internal)
335-
336-
child <- split_data$`FALSE`
337-
internal <- split_data$`TRUE`
338-
339-
internal$internal_child <- internal$child
340-
internal$child <- NULL
341-
342-
child$parent_ <- child$parent
343-
344-
rhs <- nest_(child, "child", setdiff(names(child), "parent_"))
345-
346-
nested <- left_join(internal, rhs, by = c("id" = "parent_"))
347-
348-
children <- nested$child
349-
for (i in seq_along(children)) {
350-
new <- combine_children(children[[i]], nested$internal_child[[i]])
351-
# Work around is.null(new)
352-
children[i] <- list(new)
353-
}
354-
nested$child <- children
355-
nested$internal_child <- NULL
356-
nest_parse_data(nested)
357359
}
358360

359361
#' Combine child and internal child

R/roxygen-examples-parse.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ emulate_rd <- function(roxygen) {
143143
)
144144
roxygen <- gsub("(^#)[^']", "#' #", roxygen)
145145

146-
text <- roxygen2::roc_proc_text(
146+
processed <- roxygen2::roc_proc_text(
147147
roxygen2::rd_roclet(),
148148
paste(roxygen, collapse = "\n")
149-
)[[1L]]$get_section("examples")
149+
)
150+
151+
text <- processed[[1L]]$get_section("examples")
150152
text <- as.character(text)[-1L]
151153
text <- c(
152154
if (grepl("^#'(\\s|\t)*@examples(\\s|\t)*$", roxygen[2L])) "",

tests/testthat/_snaps/public_api-1.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# messages (via cat()) of style_file are correct
2+
3+
Code
4+
cat(catch_style_file_output(file.path("public-api", "xyzdir-dirty",
5+
"dirty-sample-with-scope-tokens.R")), sep = "\n")
6+
Output
7+
Styling 1 files:
8+
dirty-sample-with-scope-tokens.R i
9+
----------------------------------------
10+
Status Count Legend
11+
v 0 File unchanged.
12+
i 1 File changed.
13+
x 0 Styling threw an error.
14+
----------------------------------------
15+
Please review the changes carefully!
16+
17+
---
18+
19+
Code
20+
cat(catch_style_file_output(file.path("public-api", "xyzdir-dirty",
21+
"clean-sample-with-scope-tokens.R")), sep = "\n")
22+
Output
23+
Styling 1 files:
24+
clean-sample-with-scope-tokens.R v
25+
----------------------------------------
26+
Status Count Legend
27+
v 1 File unchanged.
28+
i 0 File changed.
29+
x 0 Styling threw an error.
30+
----------------------------------------
31+
32+
---
33+
34+
Code
35+
cat(catch_style_file_output(file.path("public-api", "xyzdir-dirty",
36+
"dirty-sample-with-scope-spaces.R")), sep = "\n")
37+
Output
38+
Styling 1 files:
39+
dirty-sample-with-scope-spaces.R i
40+
----------------------------------------
41+
Status Count Legend
42+
v 0 File unchanged.
43+
i 1 File changed.
44+
x 0 Styling threw an error.
45+
----------------------------------------
46+
Please review the changes carefully!
47+

tests/testthat/_snaps/public_api-3.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# No sensitive to decimal option
2+
3+
Code
4+
style_text("1")
5+
Output
6+
1
7+

0 commit comments

Comments
 (0)