Separate commented and non-commented lines from text
separate_commented_lines.Rd
This function extracts and separates commented and non-commented parts from a given vector of texts. It uses a specified delimiter pair to identify comments and returns a data frame with the full text, extracted comments, and remaining code lines.
Usage
separate_commented_lines(texts, delim_pair = c(`/*` = "*/"), .verbose = T)
Value
A data frame with three columns:
- text
The original text.
- comments
The extracted comments, concatenated together if multiple are found.
- codelines
The remaining text after removing comments.
Examples
if (FALSE) { # \dontrun{
texts <- c(
"Code snippet /* first comment */ and more code /* second comment */",
"Another line /* only a comment */",
"A line with no comments", " here one start /* commented ", " some commented line", " */"
)
separate_commented_lines(texts, delim_pair = c("/*" = "*/"), .verbose = FALSE)
} # }