Skip to content

Commit

Permalink
+3.5% is too much, let's not check newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Apr 10, 2021
1 parent f871e49 commit 35c50e1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 36 deletions.
17 changes: 4 additions & 13 deletions R/expr-is.R
Expand Up @@ -127,22 +127,13 @@ is_shebang <- function(pd) {
#' "# title",
#' "some_code <- function() {}",
#' "#+ chunk-label, opt1=value1",
#' "call(3, 2, c(3:2))"
#' "call(3, 2, c(3:2))",
#' "#> 99"
#' ))
#' @param pd A parse table.
#' @keywords internal
is_code_chunk_header_or_xaringan <- function(pd) {
grepl("^#[\\+|\\-|<<]", pd$text, perl = TRUE)
}

#' Identify output comments
#'
#' Determines if parse table contains `#>` at the beginning of a line, which is
#' often used to prefix the output value of previous R code.
#' @param pd A parse table.
#' @keywords internal
is_output_prefix <- function(pd) {
grepl("^#>", pd$text) & pd$lag_newlines > 0L
is_code_chunk_header_or_xaringan_or_code_output <- function(pd) {
grepl("^#[\\+|\\-|<<|>]", pd$text, perl = TRUE)
}

contains_else_expr <- function(pd) {
Expand Down
3 changes: 1 addition & 2 deletions R/rules-spaces.R
Expand Up @@ -252,8 +252,7 @@ start_comments_with_space <- function(pd, force_one = FALSE) {
if (any(is_comment)) {
is_comment <- is_comment &
!is_shebang(pd) &
!is_code_chunk_header_or_xaringan(pd) &
!is_output_prefix(pd)
!is_code_chunk_header_or_xaringan_or_code_output(pd)
if (!any(is_comment)) {
return(pd)
}
Expand Down

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

16 changes: 0 additions & 16 deletions man/is_output_prefix.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion tests/testthat/parse_comments/output-prefix-out.R
Expand Up @@ -2,7 +2,7 @@ this()
#> is output


this() # > is not
this() #> is not

this()
# > not sure

0 comments on commit 35c50e1

Please sign in to comment.