CodeDepends (version 0.6.5)

readScript: Read the code blocks/chunks from a document

Description

This is a general function that determines the type of the document and then extracts the code from it.

This is an S4 generic and so can be extended by other packages for document types that have a class, e.g. Word or OpenOffice documents.

readAnnotatedScript is for reading scripts that use a vocabulary to label code blocks with high-level task identifiers to indicate what the code does in descriptive terms.

Usage

readScript(doc, type = NA, txt = readLines(doc), ...)
readAnnotatedScript(doc, txt = readLines(doc))

Arguments

doc

the document, typically a string giving the file name. This can also be a connection, e.g. created via url.

type

a string indicating the type of the document. If this is missing, the function calls getDocType to attempt to determine this based on the "common" types of documents.

txt

the lines of text of the document.

...

Passed to low-level input functions used by various methods.

Value

A list of the R expressions that constitute the code blocks.

See Also

parse

Examples

Run this code
# NOT RUN {
  e = readScript( system.file ("samples", "dual.R", package = "CodeDepends") )
  
# }
# NOT RUN {
  readScript(url("http://www.omegahat.net/CodeDepends/formula.R"))
# }

Run the code above in your browser using DataLab