R/core.R

Defines functions nocomments_style

Documented in nocomments_style

version <- unlist(unname(read.dcf("DESCRIPTION")[, "Version"]))

#' The nocomments style
#'
#' Style code according to the nocomments style guide. For more
#' details and docs, see the [styler::tidyverse_style()].
#' @inheritParams styler::tidyverse_style
#' @family obtain transformers
#' @family style_guides
#' @examples
#' style_text("call( 1)", scope = "spaces")
#' @importFrom purrr partial
#' @export
nocomments_style <- function(scope = "tokens",
                             strict = TRUE,
                             indent_by = 2,
                             start_comments_with_one_space = FALSE,
                             reindention = tidyverse_reindention(),
                             math_token_spacing = tidyverse_math_token_spacing()) {
  args <- as.list(environment())
  scope <- styler:::scope_normalize(scope)
  indention_manipulators <- if ("indention" %in% scope) {
    list()
  }
  space_manipulators <- if ("spaces" %in% scope) {
    list()
  }

  use_raw_indention <- !("indention" %in% scope)

  line_break_manipulators <- if ("line_breaks" %in% scope) {
    list()
  }

  token_manipulators <- if ("tokens" %in% scope) {
    list(drop_comments = drop_comments)
  }



  create_style_guide(
    # transformer functions
    initialize = default_style_guide_attributes,
    line_break = line_break_manipulators,
    space = space_manipulators,
    indention = indention_manipulators,
    token = token_manipulators,
    # transformer options
    use_raw_indention = use_raw_indention,
    reindention = reindention,
    style_guide_name = "styler.nocomments::nocomments_style@https://github.com/lorenzwalthert/styler.nocomments/",
    style_guide_version = version,
    more_specs_style_guide = args
  )
}
lorenzwalthert/styler.nocomments documentation built on Dec. 27, 2021, 12:15 a.m.