View source: R/get_source_expressions.R
get_source_expressions | R Documentation |
This object is given as input to each linter.
get_source_expressions(filename, lines = NULL)
filename |
the file to be parsed. |
lines |
a character vector of lines.
If |
The file is read using the encoding
setting.
This setting is found by taking the first valid result from the following locations
The encoding
key from the usual lintr configuration settings.
The Encoding
field from a Package DESCRIPTION
file in a parent directory.
The Encoding
field from an R Project .Rproj
file in a parent directory.
"UTF-8"
as a fallback.
A list
with three components:
a list
of
n+1
objects. The first n
elements correspond to each expression in
filename
, and consist of a list of 9 elements:
filename
(character
)
line
(integer
) the line in filename
where this expression begins
column
(integer
) the column in filename
where this expression begins
lines
(named character
) vector of all lines spanned by this
expression, named with the line number corresponding to filename
parsed_content
(data.frame
) as given by utils::getParseData()
for this expression
xml_parsed_content
(xml_document
) the XML parse tree of this
expression as given by xmlparsedata::xml_parse_data()
content
(character
) the same as lines
as a single string (not split across lines)
The final element of expressions
is a list corresponding to the full file
consisting of 6 elements:
filename
(character
)
file_lines
(character
) the readLines()
output for this file
content
(character
) for .R files, the same as file_lines
;
for .Rmd or .qmd scripts, this is the extracted R source code (as text)
full_parsed_content
(data.frame
) as given by
utils::getParseData()
for the full content
full_xml_parsed_content
(xml_document
) the XML parse tree of all
expressions as given by xmlparsedata::xml_parse_data()
terminal_newline
(logical
) records whether filename
has a terminal
newline (as determined by readLines()
producing a corresponding warning)
A Lint
object describing any parsing error.
The readLines()
output for this file.
tmp <- withr::local_tempfile(lines = c("x <- 1", "y <- x + 1"))
get_source_expressions(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.