
Last chance! 50% off unlimited learning
Sale ends in
Check that comment delimiters and the text of comments, when there is any, are separated by at least one space.
comments_style(srcData)
Boolean. When FALSE
, a message indicates the nature of
the error and the faulty lines, and the returned value has the
following attributes:
faulty line numbers;
text of the error message.
a list as returned by getSourceData
.
Good coding practices dictate to follow the comment delimiters by at least one space when a comment contains text.
The accepted delimiters are: one or more \#
symbols possibly
followed immediately by any combination of punctuation characters of the
[:punct:]
class (see regex
).
## Keep parse data in non interactive sessions.
if (!interactive())
op <- options(keep.source = TRUE)
## Correct comments
fil <- tempfile(fileext = ".R")
cat("### foo",
"##-- bar",
"## ",
"#",
"#***",
file = fil, sep = "\n")
comments_style(getSourceData(fil))
## Incorrect comments
fil <- tempfile(fileext = ".R")
cat("###foo",
"##++bar",
file = fil, sep = "\n")
comments_style(getSourceData(fil))
Run the code above in your browser using DataLab