find_pos_id_to_keep | R Documentation |
To make a parse table shallow, we must know which ids to keep.
split(cumsum(pd_parent_first$parent == 0L))
above puts comments with
negative parents in the same block as proceeding expressions (but also with
positive).
find_pos_id_to_keep()
must hence always keep negative comments. We did not
use split(cumsum(pd_parent_first$parent < 1L))
because then every top-level
comment is an expression on its own and processing takes much longer for
typical roxygen annotated code.
find_pos_id_to_keep(pd)
pd |
A temporary top-level nest where the first expression is always a top-level expression, potentially cached. |
Note that top-level comments above code have negative parents (the negative value of the parent of the code expression that follows after, another comment might be in the way though), all comments that are not top level have positive ids. All comments for which no code follows afterwards have parent 0.
styler:::get_parse_data(c("#", "1"))
styler:::get_parse_data(c("c(#", "1)"))
styler:::get_parse_data(c("", "c(#", "1)", "#"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.