Skip to content

Commit cecad69

Browse files
alignment and spare blank lines
1 parent d005106 commit cecad69

File tree

4 files changed

+41
-46
lines changed

4 files changed

+41
-46
lines changed

R/transform-files.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Transform files with transformer functions
22
#'
33
#' `transform_files` applies transformations to file contents and writes back
4-
#' the result.
4+
#' the result.
55
#' @param files A character vector with paths to the file that should be
66
#' transformed.
77
#' @inheritParams make_transformer
@@ -71,8 +71,8 @@ transform_file <- function(path,
7171
#' Closure to return a transformer function
7272
#'
7373
#' This function takes a list of transformer functions as input and
74-
#' returns a function that can be applied to character strings
75-
#' that should be transformed.
74+
#' returns a function that can be applied to character strings
75+
#' that should be transformed.
7676
#' @param transformers A list of transformer functions that operate on flat
7777
#' parse tables.
7878
make_transformer <- function(transformers) {

R/visit.R

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#' Visit'em all
22
#'
33
#' Apply a list of functions to each level in a nested parse table.
4-
#' `pre_visit()` applies `funs` before it proceeds to the children,
5-
#' (that is, starts from the outermost level of nesting progressing
6-
#' to the innermost level), `post_visit()` proceeds to its children
7-
#' before applying the functions (meaning it first applies the functions
8-
#' to the innermost level of nesting first and then going outwards).
4+
#' `pre_visit()` applies `funs` before it proceeds to the children,
5+
#' (that is, starts from the outermost level of nesting progressing
6+
#' to the innermost level), `post_visit()` proceeds to its children
7+
#' before applying the functions (meaning it first applies the functions
8+
#' to the innermost level of nesting first and then going outwards).
99
#' @param pd_nested A nested parse table.
1010
#' @inheritParams visit_one
1111
#' @family visitors
@@ -46,13 +46,12 @@ visit_one <- function(pd_flat, funs) {
4646
)
4747
}
4848

49-
5049
#' Propagate context to terminals
5150
#'
5251
#' Implements a very specific pre-visiting scheme, namely to propagate
53-
#' indention, spaces and lag_newlines to inner token to terminals. This means
54-
#' that information regarding indention, line breaks and spaces (which is
55-
#' relative in `pd_nested`) will be converted into absolute.
52+
#' indention, spaces and lag_newlines to inner token to terminals. This means
53+
#' that information regarding indention, line breaks and spaces (which is
54+
#' relative in `pd_nested`) will be converted into absolute.
5655
#' @inherit context_towards_terminals
5756
#' @seealso context_towards_terminals visitors
5857
#' @importFrom purrr pmap
@@ -80,14 +79,13 @@ context_to_terminals <- function(pd_nested,
8079
pd_transformed
8180
}
8281

83-
8482
#' Update the a parse table given outer context
8583
#'
8684
#' `outer_lag_newlines` are added to the first token in `pd`,
87-
#' `outer_indent` is added to all tokens in `pd`, `outer_spaces` is added to
88-
#' the last token in `pd`. [context_to_terminals()] calls this function
89-
#' repeatedly, which means the propagation of the parse information to the
90-
#' terminal tokens.
85+
#' `outer_indent` is added to all tokens in `pd`, `outer_spaces` is added to
86+
#' the last token in `pd`. [context_to_terminals()] calls this function
87+
#' repeatedly, which means the propagation of the parse information to the
88+
#' terminal tokens.
9189
#' @param pd_nested A nested parse table.
9290
#' @param outer_lag_newlines The lag_newlines to be propagated inwards.
9391
#' @param outer_indent The indention depth to be propagated inwards.
@@ -113,30 +111,30 @@ context_towards_terminals <- function(pd_nested,
113111
#' Extract terminal tokens
114112
#'
115113
#' Turns a nested parse table into a flat parse table and extracts *all*
116-
#' attributes
114+
#' attributes.
117115
#' @param pd_nested A nested parse table.
118116
extract_terminals <- function(pd_nested) {
119117
if (is.null(pd_nested)) return(pd)
120118
pd_split <- split(pd_nested, seq_len(nrow(pd_nested)))
121119
bind_rows(if_else(pd_nested$terminal, pd_split, pd_nested$child))
122120
}
123121

124-
125122
#' Enrich flattened parse table
126123
#'
127124
#' Enriches a flattened parse table with terminals only. In particular, it is
128-
#' possible to compute the exact position a token will have (line and column)
129-
#' when it will be serialized.
130-
#' @details Since we have only terminal tokens now, the line on which a token
131-
#' starts we also be the line on which it ends. We call `line1` the line on
132-
#' which the token starts. `line1` has the same meaning as `line1` that can be
133-
#' found in a flat parse table (see [tokenize()]), just that the `line1`
134-
#' created by `enrich_terminals()` is the updated version of the former
135-
#' `line1`. The same applies for `col1` and `col2`. Note that this function
136-
#' does remove the columns `indent` and `spaces.` All information of the former
137-
#' is stored in `lag_spaces` now. The later was removed because it is redundant
138-
#' after adding the column `lag_spaces`, which is more convenient to work with,
139-
#' in particular when serializing the parse table.
125+
#' possible to compute the exact position a token will have (line and column)
126+
#' when it will be serialized.
127+
#' @details
128+
#' Since we have only terminal tokens now, the line on which a token
129+
#' starts we also be the line on which it ends. We call `line1` the line on
130+
#' which the token starts. `line1` has the same meaning as `line1` that can be
131+
#' found in a flat parse table (see [tokenize()]), just that the `line1`
132+
#' created by `enrich_terminals()` is the updated version of the former
133+
#' `line1`. The same applies for `col1` and `col2`. Note that this function
134+
#' does remove the columns `indent` and `spaces.` All information of the former
135+
#' is stored in `lag_spaces` now. The later was removed because it is redundant
136+
#' after adding the column `lag_spaces`, which is more convenient to work with,
137+
#' in particular when serializing the parse table.
140138
#' @inheritParams choose_indention
141139
enrich_terminals <- function(flattened_pd, use_raw_indention = FALSE) {
142140
flattened_pd$lag_spaces <- lag(flattened_pd$spaces, default = 0L)
@@ -162,18 +160,17 @@ enrich_terminals <- function(flattened_pd, use_raw_indention = FALSE) {
162160
#' Choose the indention method for the tokens
163161
#'
164162
#' Either use the raw indention, which is just the spaces computed between
165-
#' the first token on a new line and the token before it, or use the indention
166-
#' computed according to the transformer used, which is stored in the column
167-
#' `indention`.
168-
#'
169-
#' All indention information will be combined with the space information for
170-
#' the first token on a new line.
171-
#' If `use_raw_indention` is set, information in the column `indention` will
172-
#' be discarded anyways. If it is not set, the first token on a new line will
173-
#' "inherit" the indention of the whole line.
174-
#' The column `indention` will be removed since all information necessary is
175-
#' contained in the spacing information of the first token on a new line and
176-
#' the position of the tokens will not be changed anymore at this stage.
163+
#' the first token on a new line and the token before it, or use the indention
164+
#' computed according to the transformer used, which is stored in the column
165+
#' `indention`.
166+
#' All indention information will be combined with the space information for
167+
#' the first token on a new line.
168+
#' If `use_raw_indention` is set, information in the column `indention` will
169+
#' be discarded anyways. If it is not set, the first token on a new line will
170+
#' "inherit" the indention of the whole line.
171+
#' The column `indention` will be removed since all information necessary is
172+
#' contained in the spacing information of the first token on a new line and
173+
#' the position of the tokens will not be changed anymore at this stage.
177174
#' @param flattened_pd A nested parse table that was turned into a flat parse
178175
#' table using [extract_terminals()].
179176
#' @param use_raw_indention Boolean indicating whether or not the raw indention

man/choose_indention.Rd

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/extract_terminals.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)