Skip to content

Commit 9b0faa2

Browse files
Merge pull request #958 from IndrajeetPatil/edits_to_vignettes
docs: edits to vignettes
2 parents e0116c8 + 9422a3d commit 9b0faa2

13 files changed

+21
-18
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ editor_options:
3535
- Old (and outdated) vignettes have been removed (\@IndrajeetPatil, #955).
3636
To access them, do `git checkout v1.0.0`.
3737
- Upgrade testing infra to testthat 3e (\@IndrajeetPatil, #949).
38+
- Minor improvements to the documentation (\@IndrajeetPatil, #958).
3839
- All (R)md files in this project's source code are now formatted with
3940
default pandoc markdown formatter. This conversion is required when using
4041
the visual mode in RStudio (#941).

R/styler.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#' Non-invasive pretty printing of R code
22
#'
3-
#' styler allows you to format .R files, packages or entire R source trees
3+
#' styler allows you to format `.R`, `.Rmd`, `.Rmarkdown` and/or
4+
#' `.qmd`, `.Rnw` files, R packages, or entire R source trees
45
#' according to a style guide.
56
#' The following functions can be used for styling:
67
#' * [style_text()] to style a character vector.
7-
#' * [style_file()] to style a single .R file.
8-
#' * [style_dir()] to style all .R files in a directory.
8+
#' * [style_file()] to style a single file.
9+
#' * [style_dir()] to style all files in a directory.
910
#' * [style_pkg()] to style the source files of an R package.
1011
#' * [styler_addins] (RStudio Addins) to style either selected code or the
1112
#' active file.

R/ui-caching.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' `NULL`, the option "styler.cache_name" is considered which defaults to
99
#' the version of styler used.
1010
#' @details
11-
#' Each version of styler has it's own cache by default, because styling is
11+
#' Each version of styler has its own cache by default, because styling is
1212
#' potentially different with different versions of styler.
1313
#' @param ask Whether or not to interactively ask the user again.
1414
#' @family cache managers
@@ -61,7 +61,7 @@ NULL
6161
#'
6262
#' Gives information about the cache. Note that the size consumed by the cache
6363
#' will always be displayed as zero because all the cache does is creating an
64-
#' empty file of size 0 bytes for every cached expression. The innode is
64+
#' empty file of size 0 bytes for every cached expression. The inode is
6565
#' excluded from this displayed size but negligible.
6666
#' @param cache_name The name of the cache for which to show details. If
6767
#' `NULL`, the active cache is used. If none is active the cache corresponding

R/ui-styling.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @api
1+
#' @keywords api
22
#' @import tibble
33
#' @importFrom magrittr %>%
44
NULL

inst/WORDLIST

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ifelse
8585
impl
8686
infinitively
8787
initializer
88-
innode
88+
inode
8989
integrations
9090
interaces
9191
invasiveness

man/cache_clear.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.

man/cache_info.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.

man/styler-package.Rd

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

vignettes/caching.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ knitr::opts_chunk$set(
1818
library(styler)
1919
```
2020

21-
This is a developer vignette to explain how caching works and what we learned on the way. To use the caching feature, please have a look at the README.
21+
This is a developer vignette to explain how caching works and what we learned on the way.
2222

2323
The main caching features were implemented in the following two pull requests:
2424

25-
- #538: Implemented simple caching and utilities for managing caches. Input text is styled as a whole and added to the cache afterwards. This makes most sense given that the very same expression will probably never be passed to styler, unless it is already compliant with the style guide. Apart from the (negligible) innode, caching text has a memory cost of 0. Speed boosts only result if the whole text passed to styler is compliant to the style guide in use. Changing one line in a file with hundreds of lines means each line will be styled again. This is a major drawback and makes the cache only useful for a use with a pre-commit framework (the initial motivation) or when functions like `style_pkg()` are run often and most files were not changed.
25+
- #538: Implemented simple caching and utilities for managing caches. Input text is styled as a whole and added to the cache afterwards. This makes most sense given that the very same expression will probably never be passed to styler, unless it is already compliant with the style guide. Apart from the (negligible) inode, caching text has a memory cost of 0. Speed boosts only result if the whole text passed to styler is compliant to the style guide in use. Changing one line in a file with hundreds of lines means each line will be styled again. This is a major drawback and makes the cache only useful for a use with a pre-commit framework (the initial motivation) or when functions like `style_pkg()` are run often and most files were not changed.
2626

2727
- #578: Adds a second layer of caching by caching top-level expressions individually. This will bring speed boosts to the situation where very little is changed but there are many top-level expressions. Hence, changing one line in a big file will invalidate the cache for the expression the line is part of, i.e. when changing `x <- 2` to `x = 2` below, styler will have to restyle the function definition, but not `another(call)` and all other expressions that were not changed.
2828

vignettes/customizing_styler.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This vignette provides a high-level overview of how styler works and how you can
1313

1414
There are three major steps that styler performs in order to style code:
1515

16-
1. Create an abstract syntax tree (AST) from `utils::getParseData()` that contains positional information for every token. We call this a nested parse table. You can learn more about how exactly this is done in the vignettes "Data Structures" and "Manipulating the nested parse table".
16+
1. Create an abstract syntax tree (AST) from `utils::getParseData()` that contains positional information for every token. We call this a nested parse table.
1717

1818
2. Apply transformer functions at each level of the nested parse table. We use a visitor approach, i.e. a function that takes functions as arguments and applies them to every level of nesting. You can find out more about it on the help file for `visit()`. Note that the function is not exported by styler. The visitor will take care of applying the functions on every level of nesting - and we can supply transformer functions that operate on one level of nesting. In the sequel, we use the term *nest* to refer to such a parse table at one level of nesting. A *nest* always represents a complete expression. Before we apply the transformers, we have to initialize two columns `lag_newlines` and `spaces`, which contain the number of line breaks before the token and the number of spaces after the token. These will be the columns that most of our transformer functions will modify.
1919

0 commit comments

Comments
 (0)