Title: | Dynamic document tools |
---|---|
Description: | A set of functions to create and interact with dynamic documents and vignettes. |
Authors: | R. Gentleman, Jeff Gentry |
Maintainer: | Bioconductor Package Maintainer <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.85.0 |
Built: | 2024-10-30 05:27:02 UTC |
Source: | https://github.com/bioc/DynDoc |
This class is essentially a wrapper for the
codeChunk
class. It contains all of the codeChunks
from
a vignette file.
Objects can be created by calls of the form new("chunkList", ...)
.
chunks
:Object of class "list"
Stores a list of
codeChunk
objects, representing all of the code chunks from a
vignette file.
evalEnv
:Object of class "environment"
An
environment used for evaluation of the code chunks.
signature(object = "chunkList")
: Displays verbose
information about the code chunks
signature(object = "chunkList")
: Retrieves a
list of codeChunk
objects
signature(object = "chunkList")
:
Collapses all of the code chunks into one block of code and
returns this
signature(object = "chunkList")
: Retrieves a
specific code chunk
signature(object = "chunkList")
: Returns the
number of code chunks in this object
signature(object = "chunkList", value="character")
: Changes
the code in a given codeChunk
contained by this object
signature(object = "chunkList")
: A less
verbose display of information about the object
signature(object = "chunkList",
pos="numeric")
: Evaluates the code chunk at the specified
position in the chunkList
object
Jeff Gentry
Sweave
, codeChunk
, vignetteCode
library("utils") testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package="utils") z <- Stangle(testfile,driver=tangleToR)
library("utils") testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package="utils") z <- Stangle(testfile,driver=tangleToR)
A class to wrap necessary information for a code chunk from a vignette file.
Objects can be created by calls of the form new("codeChunk", ...)
.
chunkName
:Object of class "character"
The name
(if one exists) for the code chunk
chunk
:Object of class "character"
The code
from the code chunk
options
:Object of class "SweaveOptions"
Any
options that were set at the time the code chunk appears in the
vignette file
signature(object = "codeChunk",
env="environment")
: Will evaluate the code in the code chunk
using the environment specified. If no environment is specified,
.GlobalEnv is used.
signature(object = "codeChunk")
: Displays the
information for the code chunk
signature(object = "codeChunk",
value="character")
: Edits the chunk
slot of the object
signature(object = "codeChunk")
: Returns the
chunk
slot of the object
signature(object = "codeChunk")
: Returns the
name of the code chunk
signature(object = "codeChunk")
: Returns
the actual options from the options
slot.
signature(object = "codeChunk")
: Returns
the object stored in the options
slot.
Jeff Gentry
Sweave
, SweaveOptions
, chunkList
require("utils") testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package="utils") z <- Stangle(testfile,driver=tangleToR) getChunk(z,1)
require("utils") testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package="utils") z <- Stangle(testfile,driver=tangleToR) getChunk(z,1)
The DynDoc class is used to represent dynamic documents and vignettes in R.
indexEntry
:Object of class "character"
The
IndexEntry value from the document file
title
:Object of class "character"
The name of
the document
path
:Object of class "character"
The path to
the locally stored file
pdfPath
:Object of class "character"
The path
to a PDF rendition of the document
depends
:Object of class "character"
Any
package dependencies for the document
requires
:Object of class "character"
Any
requires level dependencies for the document
suggests
:Object of class "character"
Any
suggests level dependencies for the document
keywords
:Object of class "character"
Any
keywords for the document
codeChunks
:Object of class "chunkList"
The
code chunks contained in this document
signature(object = "DynDoc")
: Display information
about the dynamic document
signature(object = "DynDoc")
: A more succinct
informational display
signature(object = "DynDoc")
: Returns the code
chunks - currently in only for historical compatability with old code
signature(object = "DynDoc")
: Returns the
code chunks
signature(object = "DynDoc")
: Will evaluate
the R code contained in a chunk
signature(object = "DynDoc")
: Retrieves a
specific code chunk
signature(object = "DynDoc")
: Obtain the
Depends slot of the object
signature(object = "DynDoc")
: Obtain the
keywords slot of the object
signature(object = "DynDoc")
: A get method
for the requires slot of this object
signature(object = "DynDoc")
: Obtain the
suggests slot of this object
signature(object = "DynDoc")
: Obtain the
indexEntry slot of this object
signature(object = "DynDoc")
: Returns the
number of code chunks for this document
signature(object = "DynDoc")
: Obtain the path
slot of this object
signature(object = "DynDoc")
: Obtain the
pdfPath slot of this object
signature(object = "DynDoc")
: Change the
code for one of the code chunks.
Jeff Gentry
Functionality to retrive vignette metadata, on a per-vignette or a per-package level.
getPkgVigList(pkg, vigDescFun=baseVigDesc, vigPath = "/doc/", vigExt="\\.(Rnw|Snw|rnw|snw|Rtex)$", pkgVers = TRUE) getVigInfo(vig,pkg=NULL, vigDescFun=baseVigDesc, pkgVers=TRUE)
getPkgVigList(pkg, vigDescFun=baseVigDesc, vigPath = "/doc/", vigExt="\\.(Rnw|Snw|rnw|snw|Rtex)$", pkgVers = TRUE) getVigInfo(vig,pkg=NULL, vigDescFun=baseVigDesc, pkgVers=TRUE)
pkg |
Path to a package directory |
vig |
Filename of a vignette |
vigDescFun |
Function to provide output string for display |
vigPath |
Path to directory that contains vignettes in the package |
vigExt |
Regular expression pattern to match vignette file extensions |
pkgVers |
Record the package version with the other vignette metadata |
getPkgVigList: This function will look at all vignette files in the directory
<pkg>/<vigPath>
. It will then extract any header information (using
getVigInfo
), and return a list of this information.
getVigInfo: This function will retrieve the metadata from a particular vignette file. Any line starting with '%\Vignette' is taken to be metadata. Common values include VignetteIndexEntry (required), VignetteKeywords, VignetteDepends, etc. A named list of lists is returned to the user, where the names correspond to the particular metadata variable.
Both functions take a parameter baseVigDesc
, which is a
function to provide the output string to correspond with a vignette
summary. This function is directly called by getVigInfo
. It
takes one parameter, which is a vigInfo list from getVigInfo
.
Jeff Gentry
## Not run: ## We need a vignette for this to work dynPath <- system.file(package="DynDoc") vigList <- getPkgVigList(dynPath) vigList ## End(Not run)
## Not run: ## We need a vignette for this to work dynPath <- system.file(package="DynDoc") vigList <- getPkgVigList(dynPath) vigList ## End(Not run)
This function will take a vignette file and return a Vignette object in R which can be manipulated further.
getVignette(vigPath, eval = TRUE)
getVignette(vigPath, eval = TRUE)
vigPath |
The file path of the vignette file |
eval |
Whether or not to evaluate the code chunks |
This function should still be considered experimental
A valid Vignette
object representing this vignette
Jeff Gentry
These functions allow for processing and management of vignette code chunks within R. Users can directly manipulate the code chunks, as well as evaluate them at their option.
getVignetteCode(vigPath, evalEnv = new.env()) editVignetteCode(vigCode, pos, code)
getVignetteCode(vigPath, evalEnv = new.env()) editVignetteCode(vigCode, pos, code)
vigPath |
File path of vignette file to process |
evalEnv |
An environment to use for chunk evaluations |
vigCode |
The |
pos |
The position of the code chunk to edit |
code |
The new code chunk |
getVignetteCode
: This function will call Stangle
using
the tangleToR
driver in order to retrieve the code chunks from
the specified vignette file. It will then compile the other pertinent
information and return a new vignetteCode
object.
editVignetteCode
: This function will edit a code chunk
contained within a vignetteCode
and return a new object
representing that change. The evaluation environment in the new
object is a copy of the original as well, *not* the same environment.
Jeff Gentry
Given a vignette filename, will read in the vignette header metadata.
getVignetteHeader(vig, field) hasVigHeaderField(vig, field="VignetteIndexEntry")
getVignetteHeader(vig, field) hasVigHeaderField(vig, field="VignetteIndexEntry")
vig |
Vignette filename |
field |
A specific field to extract |
The getVignetteHeader
function will extract the metadata from a
vignette file and return it as a named list, where the names of the
list elements correspond to the metadata fields, and the elements
themselves the values. If a specific field is desired, it can be
specified with the 'field' argument.
The hasVigHeaderField
function is a simple wrapper around
getVignetteHeader
and will most likely be removed in the very
near future. It just is a boolean to report if a given header field
exists or not.
Jeff Gentry
A small class designed to hold a set of Sweave options
Objects can be created by calls of the form new("SweaveOptions", ...)
.
options
:Object of class "list"
A list of
strings representing options from a Sweave document.
signature(object = "SweaveOptions")
: Outputs the options
signature(object = "SweaveOptions")
:
Retrieves the options
signature(object = "SweaveOptions")
:
Returns the number of options
Jeff Gentry
A driver function for Sweave
which will provide the user with
code chunks from a vignette file within R. Functionality is very
similar to that provided by Stangle
except that an R object is
returned as opposed to the chunks being written to a file.
tangleToR()
tangleToR()
An object of type chunkList
is returned, which contains the
code chunks from the vignette file.
Jeff Gentry
require("utils") testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package="utils") z <- Stangle(testfile,driver=tangleToR)
require("utils") testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package="utils") z <- Stangle(testfile,driver=tangleToR)
This is a class that will represent a vignette file in R, it extends the DynDoc class
package
:Object of class "character"
The
package that this vignette is associated with
vigPkgVersion
:Object of class "VersionNumber"
The
version number for this vignette's package
indexEntry
:Object of class "character", from
class "DynDoc"
The VignetteIndexEntry field from the document file
title
:Object of class "character", from class
"DynDoc"
The title of the vignette
path
:Object of class "character", from class
"DynDoc"
The path to the vignette file stored locally
pdfPath
:Object of class "character", from class
"DynDoc"
The path to a PDF representation of the vignette
depends
:Object of class "character", from class
"DynDoc"
Any package dependencies for this vignette
requires
:Object of class "character", from
class "DynDoc"
Any requires level dependencies for this vignette
suggests
:Object of class "character", from
class "DynDoc"
Any suggests level dependencies for this vignette
keywords
:Object of class "character", from
class "DynDoc"
Any keywords for this vignette
codeChunks
:Object of class "chunkList", from
class "DynDoc"
A list of code chunks from this vignette
Class "DynDoc"
, directly.
signature(object = "Vignette")
: Retrieves the
package name that this vignette is associated with
signature(object = "Vignette")
: Retrieves
the version of the package that this vignette is associated with
The Vignette
class is extending the DynDoc
class by
further associating the DynDoc
concepts with a specific R
package.
Jeff Gentry
This class represents the code chunks and other related information from a vignette file. It also provides for the ability to evaulate the code chunks in a separate environment.
Objects can be created by calls of the form new("vignetteCode", ...)
Also, a helper function getVignetteCode
is provided that will do
all of the dirty work required to retrieve a vignetteCode
object
from a vignette file.
chunkList
:Object of class "chunkList"
Holds
the code chunks from the vignette file
path
:Object of class "character"
The path of
the vignette file
vigPackage
:Object of class "character"
The
package (if appropriate) that the vignette came from
depends
:Object of class "character"
Any
package dependencies for the vignette
evalEnv
:Object of class "environment"
An
environment used for evaluation of the code chunks.
signature(object = "vignetteCode")
: Displays
information about the code contained in the object
signature(object = "vignetteCode")
:
Retrieves the chunkList
object.
signature(object = "vignetteCode")
: Retrieves
the actual code chunks (not wrapped by the chunkList
class)
signature(object = "vignetteCode")
: Returns
the list of package dependencies for this vignette
signature(object =
"vignetteCode",pos="numeric")
: Will evaulate the specified code
chunk in the evalEnv
environment
signature(object = "vignetteCode")
: Returns
the evaluation environment
signature(object =
"vignetteCode",pos="numeric")
: Returns the codeChunk
object representing the specified code chunk position
signature(object = "vignetteCode")
: Returns
the number of chunks in the object
signature(object = "vignetteCode")
: Returns
the package the vignette is a part of
signature(object = "vignetteCode")
: Returns the
local file path to the vignette
signature(object =
"vignetteCode",pos="numeric", value="character")
: Resets the
code chunk specified by pos
to contain the code specified
by value
signature(object = "vignetteCode")
: A less
verbose output of information then with show
Jeff Gentry
Sweave
, getVignetteCode
,
editVignetteCode
, chunkList