## Keep parse data in non interactive sessions.
if (!interactive())
op <- options(keep.source = TRUE)
## Correct script without trailing blank lines
fil <- tempfile(fileext = ".R")
cat("## A simple function",
"foo <- function(x, y)",
"{",
" x + y",
"}",
file = fil, sep = "\n")
trailing_blank_lines_style(getSourceData(fil))
## Incorrect script with trailing blank lines
fil <- tempfile(fileext = ".R")
cat("## A simple function",
"foo <- function(x, y)",
"{",
" x + y",
"}",
"",
"",
file = fil, sep = "\n")
trailing_blank_lines_style(getSourceData(fil))
Run the code above in your browser using DataLab