Skip to content

Commit 58276a9

Browse files
improving spelling and content
1 parent 0d94260 commit 58276a9

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

vignettes/customizing_styler.Rmd

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ There are three major steps that styler performs in order to style code:
3333
the nested parse table and add spaces and line breaks between them as
3434
specified in the nested parse table.
3535

36-
The argument transformers is, apart from the code to style, the key argument
36+
The `transformers` argument is, apart from the code to style, the key argument
3737
of functions such as `style_text()` and friends. By default, it is created
3838
via the argument `style`. The transformers are a named
3939
list of transformer functions and other arguments passed to styler. To use the
@@ -144,7 +144,7 @@ four attributes in total: `lag_newlines`, `newlines`, `spaces`, `lag_spaces`.
144144
`lag_spaces` is created from `spaces` only just before the parse table is
145145
serialized, so it is not relevant for manipulating the parse table as
146146
described above. These columns are to some degree redundant, but with just lag
147-
or lead, we would loose information on the first or the last element
147+
or lead, we would lose information on the first or the last element
148148
respectively, so we need both.
149149

150150
The sequence in which styler applies rules on each level of nesting
@@ -179,6 +179,10 @@ rules. For development purposes, you also may want to use the unexported
179179
function `test_collection()` to help you with testing your style guide. You can
180180
find more information in the help file of the function.
181181

182+
If you write functions that modify spaces, don't forget make sure
183+
you don't modify EOL spacing, since that is needed for `use_raw_indention`, as
184+
indicated in the previous paragraph.
185+
182186
Finally, take note of the naming convention. All function names starting with
183187
`set-*` correspond to the `strict` option, that is, setting some value to an
184188
exact number. `add-*` Is softer: For example, `add_spaces_around_op()`, only
@@ -242,12 +246,9 @@ Now you can style your string according to it.
242246
```{r}
243247
style_text(code, style = set_line_break_before_curly_opening_style)
244248
```
245-
Note that:
246249

247-
* We have not implemented a rule that sets the line breaks before the curly
248-
opening brace, which you probably want to for the above rule to be complete.
249-
* Note that when removing line breaks, always take care of comments, since you
250-
don't want this
250+
Note that when removing line breaks, always take care of comments, since you
251+
don't want
251252
```{r, eval = FALSE}
252253
a <- function() # comments should remain EOL
253254
{
@@ -263,6 +264,11 @@ a <- function() # comments should remain EOL {
263264
}
264265
```
265266

266-
The easiest way of taking care of that is not applying the rule
267-
if there is a comment, which can be checked for within your transformer
268-
function.
267+
The easiest way of taking care of that is not applying the rule if there is a
268+
comment before the token of interest, which can be checked for within your
269+
transformer function. The transformer function from the tidyverse style that
270+
removes line breaks before the curly opening bracket looks as follows:
271+
```{r}
272+
styler:::remove_line_break_before_curly_opening
273+
```
274+

0 commit comments

Comments
 (0)