Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
^man-md$
^fyi\.md$
^README\.md$
^cran-comments\.md$
14 changes: 10 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

cpp_format_pipeline <- function(code, indent_str, wrap, expand_if, brace_style, line_limit, function_space, control_braces) {
.Call(`_rformat_cpp_format_pipeline`, code, indent_str, wrap, expand_if, brace_style, line_limit, function_space, control_braces)
cpp_format_pipeline <- function(code, indent_str, wrap, expand_if,
brace_style, line_limit, function_space,
control_braces) {
.Call(`_rformat_cpp_format_pipeline`, code, indent_str, wrap,
expand_if, brace_style, line_limit, function_space,
control_braces)
}

cpp_format_all <- function(code, indent_str, wrap, expand_if, brace_style, line_limit, function_space, control_braces) {
.Call(`_rformat_cpp_format_all`, code, indent_str, wrap, expand_if, brace_style, line_limit, function_space, control_braces)
cpp_format_all <- function(code, indent_str, wrap, expand_if, brace_style,
line_limit, function_space, control_braces) {
.Call(`_rformat_cpp_format_all`, code, indent_str, wrap, expand_if,
brace_style, line_limit, function_space, control_braces)
}

cpp_set_trace <- function(enable) {
Expand Down
7 changes: 4 additions & 3 deletions R/ast_collapse.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ collapse_calls <- function(terms, indent_str, line_limit = 80L) {
close_line_toks <- line_index_get(lidx, close_line)
suffix_idx <- close_line_toks[
terms$out_order[close_line_toks] >
terms$out_order[close_idx]]
terms$out_order[close_idx]]
if (length(suffix_idx) > 0L) {
suffix_toks <- terms$token[suffix_idx]
# Determine which suffix tokens to keep.
Expand Down Expand Up @@ -142,8 +142,8 @@ collapse_calls <- function(terms, indent_str, line_limit = 80L) {
# Remaining tokens on close_line (not in call or suffix)
remaining_close <- close_line_toks[
terms$out_order[close_line_toks] >
terms$out_order[close_idx] &
!close_line_toks %in% suffix_idx]
terms$out_order[close_idx] &
!close_line_toks %in% suffix_idx]

# If there are remaining tokens, check if everything
# (call + suffix + remaining) would fit on one line.
Expand Down Expand Up @@ -202,3 +202,4 @@ collapse_calls <- function(terms, indent_str, line_limit = 80L) {

terms
}

5 changes: 3 additions & 2 deletions R/ast_wrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ wrap_long_calls <- function(terms, indent_str, wrap = "paren",
if (last_offset > 0L) {
trailing <- line_idx[
terms$out_order[line_idx] >
terms$out_order[close_idx] &
!line_idx %in% all_call_idx]
terms$out_order[close_idx] &
!line_idx %in% all_call_idx]
terms$out_line[trailing] <-
call_line + last_offset
}
Expand All @@ -462,3 +462,4 @@ wrap_long_calls <- function(terms, indent_str, wrap = "paren",

terms
}

4 changes: 3 additions & 1 deletion R/rformat.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#' rformat("x <- if (a) b else c", expand_if = TRUE)
#'
#' # Wrap long function signatures (default: paren-aligned)
#' long_sig <- "f <- function(alpha, beta, gamma, delta, epsilon, zeta, eta, theta, iota, kappa) {\n 1\n}"
#' long_sig <- paste0(
#' "f <- function(alpha, beta, gamma, delta, ",
#' "epsilon, zeta, eta) {\n 1\n}")
#' cat(rformat(long_sig), sep = "\n")
#'
#' # Wrap with fixed 8-space continuation indent
Expand Down
1 change: 1 addition & 0 deletions R/zzz_rcpp.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#' @useDynLib rformat, .registration = TRUE
#' @importFrom Rcpp sourceCpp
NULL

18 changes: 18 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Test environments

* Ubuntu 24.04 LTS, R 4.5.2
* R-hub (via win-builder)

## R CMD check results

0 errors | 0 warnings | 2 notes

* New submission.
* Non-portable compilation flags from system R configuration (not
package-specific).

## Additional testing

Stress tested against all R files from 126 CRAN and base R packages
with randomized style parameters: 0 parse failures, 0 idempotency
exceptions.
4 changes: 3 additions & 1 deletion man/rformat.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ rformat("if(x>0) y<-1", control_braces = TRUE)
rformat("x <- if (a) b else c", expand_if = TRUE)

# Wrap long function signatures (default: paren-aligned)
long_sig <- "f <- function(alpha, beta, gamma, delta, epsilon, zeta, eta, theta, iota, kappa) {\n 1\n}"
long_sig <- paste0(
"f <- function(alpha, beta, gamma, delta, ",
"epsilon, zeta, eta) {\n 1\n}")
cat(rformat(long_sig), sep = "\n")

# Wrap with fixed 8-space continuation indent
Expand Down