Skip to content

Commit

Permalink
only disallow unmatched indentation of {r} and during R CMD ch…
Browse files Browse the repository at this point in the history
…eck when not running on CRAN, which means an error will be thrown if you run R CMD check locally or in Github action (in either case, you may be developing the package; if that's the case, you should fix the unbalanced chunk delimiters)

this will make the affected R packages found in #2057 stay safely on CRAN for a while (I've notified them)
  • Loading branch information
yihui committed Oct 13, 2021
1 parent e2d91b7 commit 89039cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,12 @@ match_chunk_end = function(pattern, line, i, b, lines, signal = stop) {
if (!any(match_chunk_begin(pattern, lines[i + 1:(k - 1)], '^\\1`*\\\\{')))
return(FALSE)
}
# TODO: for now we only disallow unmatched indentation during R CMD check
# that's not running on CRAN; we will fully disallow it in the future (#2057)
p = gsub('\\^\\s+', '', pattern)
if (grepl(p, line) && (is_cran() || is_bioc()) && identical(signal, stop2)) {
signal = warning2
}
signal(
'The starting backticks on line ', i, ' ("', line, '") in ', current_input(),
' do not match the chunk header, which starts with "',
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ is_cran_check = function() {
is_cran() && is_R_CMD_check()
}

is_bioc = function() Sys.getenv('BBS_HOME') != ''

# round a number to getOption('digits') decimal places by default, and format()
# it using significant digits if the option knitr.digits.signif = TRUE
round_digits = function(x) {
Expand Down

0 comments on commit 89039cb

Please sign in to comment.