Skip to content

Commit 95b9132

Browse files
spell checking
1 parent a44ae79 commit 95b9132

16 files changed

+71
-71
lines changed

R/environments.R

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
#' Work with parser versions
2-
#'
3-
#' The structure of the parse data affects many operations in styler. There was
4-
#' unexpected behaviour of the parser that styler was initially designed to work
5-
#' around. Examples are [#187](https://github.com/r-lib/styler/issues/187),
6-
#' [#216](https://github.com/r-lib/styler/issues/216),
7-
#' [#100](https://github.com/r-lib/styler/issues/100) and others. With
8-
#' [#419](https://github.com/r-lib/styler/issues/419), the structrure of the parse
9-
#' data changes and we need to dispatch for older versions. As it is inconvenient
10-
#' to pass a parser version down in the call stack in various places, the
11-
#' environment `env_current` is used to store the current version *globally*
12-
#' but internally.
13-
#'
14-
#' We version the parser as follows:
15-
#'
16-
#' * version 1: Before fix mentioned in #419.
17-
#' * version 2: After #419.
18-
#'
19-
#'The following utilities are available:
20-
#'
21-
#' * `parser_version_set()` sets the parser version in the environment
22-
#' `env_current`.
23-
#' * `parser_version_get()` retrieves the parser version from the
24-
#' environment `env_current`.
25-
#' * `parser_version_find()` determines the version of the parser from parse
26-
#' data. This does not necessarily mean that the version found is the
27-
#' actual version, but it *behaves* like it. For example, code that does not
28-
#' contain `EQ_ASSIGN` is parsed the same way with version 1 and 2. If the
29-
#' behaviour is identical, the version is set to 1.
30-
#' @param version The version of the parser to be used.
31-
#' @param pd A parse table such as the output from
32-
#' `utils::getParseData(parse(text = text))`.
33-
#' @keywords internal
34-
parser_version_set <- function(version) {
35-
env_current$parser_version <- version
36-
}
37-
38-
#' @rdname parser_version_set
39-
parser_version_get <- function() {
40-
env_current$parser_version
41-
}
42-
43-
#' @rdname parser_version_set
44-
parser_version_find <- function(pd) {
45-
ifelse(any(pd$token == "equal_assign"), 2, 1)
46-
}
47-
48-
49-
50-
env_current <- rlang::new_environment(parent = rlang::empty_env())
1+
#' Work with parser versions
2+
#'
3+
#' The structure of the parse data affects many operations in styler. There was
4+
#' unexpected behaviour of the parser that styler was initially designed to work
5+
#' around. Examples are [#187](https://github.com/r-lib/styler/issues/187),
6+
#' [#216](https://github.com/r-lib/styler/issues/216),
7+
#' [#100](https://github.com/r-lib/styler/issues/100) and others. With
8+
#' [#419](https://github.com/r-lib/styler/issues/419), the structure of the parse
9+
#' data changes and we need to dispatch for older versions. As it is inconvenient
10+
#' to pass a parser version down in the call stack in various places, the
11+
#' environment `env_current` is used to store the current version *globally*
12+
#' but internally.
13+
#'
14+
#' We version the parser as follows:
15+
#'
16+
#' * version 1: Before fix mentioned in #419.
17+
#' * version 2: After #419.
18+
#'
19+
#'The following utilities are available:
20+
#'
21+
#' * `parser_version_set()` sets the parser version in the environment
22+
#' `env_current`.
23+
#' * `parser_version_get()` retrieves the parser version from the
24+
#' environment `env_current`.
25+
#' * `parser_version_find()` determines the version of the parser from parse
26+
#' data. This does not necessarily mean that the version found is the
27+
#' actual version, but it *behaves* like it. For example, code that does not
28+
#' contain `EQ_ASSIGN` is parsed the same way with version 1 and 2. If the
29+
#' behaviour is identical, the version is set to 1.
30+
#' @param version The version of the parser to be used.
31+
#' @param pd A parse table such as the output from
32+
#' `utils::getParseData(parse(text = text))`.
33+
#' @keywords internal
34+
parser_version_set <- function(version) {
35+
env_current$parser_version <- version
36+
}
37+
38+
#' @rdname parser_version_set
39+
parser_version_get <- function() {
40+
env_current$parser_version
41+
}
42+
43+
#' @rdname parser_version_set
44+
parser_version_find <- function(pd) {
45+
ifelse(any(pd$token == "equal_assign"), 2, 1)
46+
}
47+
48+
49+
50+
env_current <- rlang::new_environment(parent = rlang::empty_env())

R/parse.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ ensure_valid_pd <- function(pd) {
193193
#' @details
194194
#' The meaning of the variable `is_problematic_string` in the source code
195195
#' changes from "all strings" to "all problematic strings", is partly
196-
#' missleading and this approach was chosen for performance reasons only.
196+
#' misleading and this approach was chosen for performance reasons only.
197197
#' @param pd A parse table.
198198
#' @param text The initial code to style.
199199
#' @keywords internal

R/roxygen-examples-parse.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ parse_roxygen <- function(roxygen) {
2727

2828
#' Changing the line definition
2929
#'
30-
#' Input: New line denoted with `\\n`. Lines can span accross elements.
30+
#' Input: New line denoted with `\\n`. Lines can span across elements.
3131
#' Output: Each element in the vector is one line.
3232
#'
3333
#' @param raw Raw code to post-process.

R/roxygen-examples.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ style_roxygen_code_example_segment <- function(one_dont, transformers) {
5353
#'
5454
#' @param code_snippet A character vector with code to style.
5555
#' @param is_dont Whether the snippet to process is a dontrun, dontshow,
56-
#' donttest segemnt or not.
56+
#' donttest segment or not.
5757
#' @inheritParams parse_transform_serialize_r
5858
#' @inheritSection parse_transform_serialize_roxygen Hierarchy
5959
#' @keywords internal

R/token-create.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ validate_new_pos_ids <- function(new_ids, after) {
120120
#' @param pd A parse table.
121121
#' @param stretch_out Whether or not to create a line break after the opening
122122
#' curly brace and before the closing curly brace.
123-
#' @param space_after How many spaces shold be inserted after the closing brace.
123+
#' @param space_after How many spaces should be inserted after the closing brace.
124124
#' @keywords internal
125125
wrap_expr_in_curly <- function(pd,
126126
stretch_out = c(FALSE, FALSE),

R/transform-files.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ make_transformer <- function(transformers, include_roxygen_examples) {
8888
#' Parse, transform and serialize roxygen comments
8989
#'
9090
#' Splits `text` into roxygen code examples and non-roxygen code examples and
91-
#' then maps over these examples by applyingj
91+
#' then maps over these examples by applying
9292
#' [style_roxygen_code_example()].
9393
#' @section Hierarchy:
9494
#' Styling involves splitting roxygen example code into segments, and segments
95-
#' into snippets. This describes the proccess for input of
95+
#' into snippets. This describes the process for input of
9696
#' [parse_transform_serialize_roxygen()]:
9797
#'
9898
#' - Splitting code into roxygen example code and other code. Downstream,
@@ -131,7 +131,7 @@ parse_transform_serialize_roxygen <- function(text, transformers) {
131131
#' @return
132132
#' A list with two elements:
133133
#'
134-
#' * A list that contains elements grouped into roxygen and non-rogxygen
134+
#' * A list that contains elements grouped into roxygen and non-roxygen
135135
#' sections. This list is named `separated`.
136136
#' * An integer vector with the indices that correspond to roxygen code
137137
#' examples in `separated`.
@@ -140,8 +140,8 @@ parse_transform_serialize_roxygen <- function(text, transformers) {
140140
split_roxygen_segments <- function(text, roxygen_examples) {
141141
if (is.null(roxygen_examples)) return(lst(separated = list(text), selectors = NULL))
142142
all_lines <- seq2(1L, length(text))
143-
active_segemnt <- as.integer(all_lines %in% roxygen_examples)
144-
segment_id <- cumsum(abs(c(0L, diff(active_segemnt)))) + 1L
143+
active_segment <- as.integer(all_lines %in% roxygen_examples)
144+
segment_id <- cumsum(abs(c(0L, diff(active_segment)))) + 1L
145145
separated <- split(text, factor(segment_id))
146146
restyle_selector <- ifelse(roxygen_examples[1] == 1L, odd_index, even_index)
147147

man/identify_insufficiently_parsed_stings.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/parse_transform_serialize_roxygen.Rd

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

man/parser_version_set.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/post_parse_roxygen.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)