\HeaderA{vignette}{View or List Vignettes}{vignette}
\aliasA{edit.vignette}{vignette}{edit.vignette}
\aliasA{print.vignette}{vignette}{print.vignette}
\keyword{documentation}{vignette}
\begin{Description}\relax
View a specified vignette, or list the available ones.
\end{Description}
\begin{Usage}
\begin{verbatim}
vignette(topic, package = NULL, lib.loc = NULL)

## S3 method for class 'vignette':
print(x, ...)
## S3 method for class 'vignette':
edit(name, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{topic}] a character string giving the (base) name of the vignette
to view. If omitted, all vignettes from all installed packages are listed.
\item[\code{package}] a character vector with the names of packages to
search through, or \code{NULL} in which case \emph{all} available
packages in the library trees specified by \code{lib.loc} are
searched.
\item[\code{lib.loc}] a character vector of directory names of \R{} libraries,
or \code{NULL}.  The default value of \code{NULL} corresponds to all
libraries currently known.
\item[\code{x, name}] Object of class \code{vignette}.
\item[\code{...}] Ignored by the \code{print} method, passed on to
\code{\LinkA{file.edit}{file.edit}} by the \code{edit} method.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Function \code{vignette} returns an object of the same class, the
print method opens a viewer for it.
Currently, only PDF versions of vignettes can be viewed.
The program specified by the \code{pdfviewer} option is used for this.
If several vignettes have PDF versions with base name identical to
\code{topic}, the first one found is used.

If no topics are given, all available vignettes are listed.  The
corresponding information is returned in an object of class
\code{"packageIQR"}.

The \code{edit} method
extracts the \R{} code from the vignette to a temporary file and
opens the file in an editor (see \code{\LinkA{edit}{edit}}). This makes it
very easy to execute the commands line by line, modify them in any way
you want to help you test variants, etc.. An alternative way of
extracting the \R{} code from the vignette is to run
\code{\LinkA{Stangle}{Stangle}} on the source code of the vignette,
see the examples below.
\end{Details}
\begin{Examples}
\begin{ExampleCode}
## List vignettes from all *installed* packages (can take long!):
vignette()

## Not run: 
## Open the grid intro vignette
vignette("grid")

## The same
v1 <- vignette("grid")
print(v1)

## Now let us have a closer look at the code
edit(v1)

## An alternative way of extracting the code,
## R file is written to current working directory
Stangle(v1$file)

## A package can have more than one vignette (package grid has several):
vignette(package="grid")
vignette("rotated")
## The same, but without searching for it:
vignette("rotated", package="grid")
## End(Not run)
\end{ExampleCode}
\end{Examples}

