Skip to content

Commit

Permalink
Merge e5b551c into a760cfb
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace authored Oct 24, 2022
2 parents a760cfb + e5b551c commit 1c84001
Showing 8 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions API
Original file line number Diff line number Diff line change
@@ -8,6 +8,10 @@ cache_deactivate(verbose = !getOption("styler.quiet", FALSE))
cache_info(cache_name = NULL, format = "both")
create_style_guide(initialize = default_style_guide_attributes, line_break = NULL, space = NULL, token = NULL, indention = NULL, use_raw_indention = FALSE, reindention = tidyverse_reindention(), style_guide_name = NULL, style_guide_version = NULL, more_specs_style_guide = NULL, transformers_drop = specify_transformers_drop(), indent_character = " ")
default_style_guide_attributes(pd_flat)
is_function_call(pd)
next_non_comment(pd, pos)
previous_non_comment(pd, pos)
scope_normalize(scope, name = substitute(scope))
specify_math_token_spacing(zero = "'^'", one = c("'+'", "'-'", "'*'", "'/'"))
specify_reindention(regex_pattern = NULL, indention = 0L, comments_only = TRUE)
specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL)
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ export(cache_deactivate)
export(cache_info)
export(create_style_guide)
export(default_style_guide_attributes)
export(is_function_call)
export(next_non_comment)
export(previous_non_comment)
export(scope_normalize)
export(specify_math_token_spacing)
export(specify_reindention)
export(specify_transformers_drop)
8 changes: 5 additions & 3 deletions R/expr-is.R
Original file line number Diff line number Diff line change
@@ -31,8 +31,12 @@ is_while_expr <- function(pd) {
pd$token[1L] == "WHILE"
}


#' Check whether `pd` is a function call
#' @describeIn pd_is Checks whether `pd` is a function call.
#' @keywords internal
#' @keywords other
#' @family third-party style guide helpers
#' @export
is_function_call <- function(pd) {
if (is.null(pd)) {
return(FALSE)
@@ -61,8 +65,6 @@ is_comment <- function(pd) {
pd$token == "COMMENT"
}



#' Check whether a parse table contains a tilde
#'
#'
2 changes: 2 additions & 0 deletions R/style-guides.R
Original file line number Diff line number Diff line change
@@ -479,6 +479,8 @@ tidyverse_reindention <- function() {
#' construction of the factor fails.
#' @keywords internal
#' @importFrom rlang abort
#' @family third-party style guide helpers
#' @export
scope_normalize <- function(scope, name = substitute(scope)) {
levels <- c("none", "spaces", "indention", "line_breaks", "tokens")
if (!all((scope %in% levels))) {
3 changes: 3 additions & 0 deletions R/utils-navigate-nest.R
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
#' @param pos The position of the token to start the search from.
#' @importFrom rlang seq2
#' @keywords internal
#' @family third-party style guide helpers
#' @export
next_non_comment <- function(pd, pos) {
if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) {
return(integer(0))
@@ -15,6 +17,7 @@ next_non_comment <- function(pd, pos) {
setdiff(candidates, which(pd$token == "COMMENT"))[1L]
}

#' @export
#' @rdname next_non_comment
previous_non_comment <- function(pd, pos) {
if (length(pos) < 1 || is.na(pos) || pos > nrow(pd)) {
6 changes: 6 additions & 0 deletions man/next_non_comment.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/pd_is.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/scope_normalize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c84001

Please sign in to comment.