Skip to content

Commit e95d346

Browse files
committed
Merge branch 'main' into f-759-named-funs
2 parents 1244cae + 0592e8e commit e95d346

35 files changed

+586
-594
lines changed

R/nest.R

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

362364
#' 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])) "",

0 commit comments

Comments
 (0)