diff --git a/R/nest.R b/R/nest.R index 09704bc9c..fb36b05c0 100644 --- a/R/nest.R +++ b/R/nest.R @@ -250,13 +250,15 @@ add_terminal_token_after <- function(pd_flat) { filter(terminal) %>% arrange_pos_id() - new_tibble(list( - pos_id = terminals$pos_id, - token_after = lead(terminals$token, default = "") - ), - nrow = nrow(terminals) - ) %>% - left_join(pd_flat, ., by = "pos_id") + rhs <- new_tibble( + list( + pos_id = terminals$pos_id, + token_after = lead(terminals$token, default = "") + ), + nrow = nrow(terminals) + ) + + left_join(pd_flat, rhs, by = "pos_id") } #' @rdname add_token_terminal @@ -266,14 +268,15 @@ add_terminal_token_before <- function(pd_flat) { filter(terminal) %>% arrange_pos_id() - new_tibble( + rhs <- new_tibble( list( id = terminals$id, token_before = lag(terminals$token, default = "") ), nrow = nrow(terminals) - ) %>% - left_join(pd_flat, ., by = "id") + ) + + left_join(pd_flat, rhs, by = "id") } @@ -351,13 +354,19 @@ nest_parse_data <- function(pd_flat) { internal$child <- NULL child$parent_ <- child$parent - joined <- - child %>% - nest_(., "child", setdiff(names(.), "parent_")) %>% - left_join(internal, ., by = c("id" = "parent_")) - nested <- joined - nested$child <- map2(nested$child, nested$internal_child, combine_children) - nested <- nested[, setdiff(names(nested), "internal_child")] + + 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) } diff --git a/R/roxygen-examples-parse.R b/R/roxygen-examples-parse.R index 1812318b2..3f2d55b95 100644 --- a/R/roxygen-examples-parse.R +++ b/R/roxygen-examples-parse.R @@ -146,9 +146,8 @@ emulate_rd <- function(roxygen) { text <- roxygen2::roc_proc_text( roxygen2::rd_roclet(), paste(roxygen, collapse = "\n") - )[[1]]$get_section("examples") %>% - as.character() %>% - .[-1] + )[[1]]$get_section("examples") + text <- as.character(text)[-1] text <- c( if (grepl("^#'(\\s|\t)*@examples(\\s|\t)*$", roxygen[2])) "", text diff --git a/R/transform-files.R b/R/transform-files.R index cf527a16a..633f82c4a 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -244,15 +244,20 @@ parse_transform_serialize_r <- function(text, transformers ) - text_out <- pd_nested %>% - split(pd_nested$block) %>% - unname() %>% - map2(find_blank_lines_to_next_block(pd_nested), - parse_transform_serialize_r_block, + pd_split <- unname(split(pd_nested, pd_nested$block)) + pd_blank <- find_blank_lines_to_next_block(pd_nested) + + text_out <- vector("list", length(pd_split)) + for (i in seq_along(pd_split)) { + text_out[[i]] <- parse_transform_serialize_r_block( + pd_split[[i]], + pd_blank[[i]], transformers = transformers, base_indention = base_indention - ) %>% - unlist() + ) + } + + text_out <- unlist(text_out) verify_roundtrip( text, text_out,