Rev 18642 | Rev 25814 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{codoc}\alias{codoc}\alias{print.codoc}\title{Check Code/Documentation Consistency}\usage{codoc(package, dir, lib.loc = NULL,use.values = FALSE, use.positions = TRUE,ignore.generic.functions = FALSE,verbose = getOption("verbose"))}\description{Find inconsistencies between actual and documented usage of \Rfunction objects in a package, by comparing names and optionally alsocorresponding positions and default values of the arguments of thefunctions.}\arguments{\item{package}{a character string naming an installed package.}\item{dir}{a character string specifying the path to a package's rootsource directory. This must contain the subdirectories \file{man}with \R documentation sources (in Rd format) and \file{R} with \Rcode. Only used if \code{package} is not given.}\item{lib.loc}{a character vector of directory names of \R libraries,or \code{NULL}. The default value of \code{NULL} corresponds to alllibraries currently known. The specified library trees are used toto search for \code{package}.}\item{use.positions}{a logical indicating whether to use the positionsof function arguments when comparing.}\item{use.values}{a logical indicating whether to use function defaultvalues when comparing code and docs.}\item{ignore.generic.functions}{if \code{TRUE}, functions the body ofwhich contains \code{"UseMethod"} are ignored.}\item{verbose}{a logical. If \code{TRUE}, additional diagnostics areprinted.}}\details{The purpose of this function is to check whether the documented usageof function objects agrees with their formal arguments as defined inthe \R code. This is not always straightforward, in particular as theusage information for methods to generic functions often employs thename of the generic rather than the method.The following algorithm is used. If an installed package is used, itis loaded (unless it is the base package), after possibly detaching analready loaded version of the package. Otherwise, if the sources areused, the \R code files of the package are collected and sourced in anew environment. Then, the usage sections of the Rd files areextracted and manipulated in order to give function stubscorresponding to the indicated usage, which are then sourced inanother new environment. For interpreted functions in both the codeand docs environment, the formals are compared according to the valuesof the arguments \code{use.positions} and \code{use.values}.Currently, synopsis sections are used, but multiple usage examples(such as in \code{\link{abline}}) are not combined when building thestubs. Occurences of synopsis sections are reported if \code{verbose}is true.}\value{An object of class \code{"codoc"} which is a list the names of whichare the names of the functions where an inconsistency was found. Theelements of the list are lists of length 2 with elements \code{code}and \code{docs}, giving the corresponding arguments obtained from thefunction's code and documented usage.There is a \code{print} method for nicely displaying the informationcontained in such objects.}\seealso{\code{\link{undoc}}}\keyword{documentation}