diff --git a/R/nest.R b/R/nest.R index 61bfb20c3..a8055775b 100644 --- a/R/nest.R +++ b/R/nest.R @@ -330,33 +330,35 @@ set_spaces <- function(spaces_after_prefix, force_one) { #' @return A nested parse table. #' @keywords internal nest_parse_data <- function(pd_flat) { - if (all(pd_flat$parent <= 0L)) { - return(pd_flat) + repeat { + if (all(pd_flat$parent <= 0L)) { + return(pd_flat) + } + pd_flat$internal <- with(pd_flat, (id %in% parent) | (parent <= 0L)) + split_data <- split(pd_flat, pd_flat$internal) + + child <- split_data$`FALSE` + internal <- split_data$`TRUE` + + internal$internal_child <- internal$child + internal$child <- NULL + + child$parent_ <- child$parent + + rhs <- nest_(child, "child", setdiff(names(child), "parent_")) + + nested <- left_join(internal, rhs, by = c("id" = "parent_")) + + children <- nested$child + for (i in seq_along(children)) { + new <- combine_children(children[[i]], nested$internal_child[[i]]) + # Work around is.null(new) + children[i] <- list(new) + } + nested$child <- children + nested$internal_child <- NULL + pd_flat <- nested } - pd_flat$internal <- with(pd_flat, (id %in% parent) | (parent <= 0L)) - split_data <- split(pd_flat, pd_flat$internal) - - child <- split_data$`FALSE` - internal <- split_data$`TRUE` - - internal$internal_child <- internal$child - internal$child <- NULL - - child$parent_ <- child$parent - - rhs <- nest_(child, "child", setdiff(names(child), "parent_")) - - nested <- left_join(internal, rhs, by = c("id" = "parent_")) - - children <- nested$child - for (i in seq_along(children)) { - new <- combine_children(children[[i]], nested$internal_child[[i]]) - # Work around is.null(new) - children[i] <- list(new) - } - nested$child <- children - nested$internal_child <- NULL - nest_parse_data(nested) } #' Combine child and internal child diff --git a/R/roxygen-examples-parse.R b/R/roxygen-examples-parse.R index 587641fef..6383fa337 100644 --- a/R/roxygen-examples-parse.R +++ b/R/roxygen-examples-parse.R @@ -143,10 +143,12 @@ emulate_rd <- function(roxygen) { ) roxygen <- gsub("(^#)[^']", "#' #", roxygen) - text <- roxygen2::roc_proc_text( + processed <- roxygen2::roc_proc_text( roxygen2::rd_roclet(), paste(roxygen, collapse = "\n") - )[[1L]]$get_section("examples") + ) + + text <- processed[[1L]]$get_section("examples") text <- as.character(text)[-1L] text <- c( if (grepl("^#'(\\s|\t)*@examples(\\s|\t)*$", roxygen[2L])) "",