Rev 53095 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/tools/man/codoc.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2009 R Core Development Team% Distributed under GPL 2 or later\name{codoc}\alias{codoc}\alias{codocClasses}\alias{codocData}\alias{print.codoc}\alias{print.codocClasses}\alias{print.codocData}\title{Check Code/Documentation Consistency}\usage{codoc(package, dir, lib.loc = NULL,use.values = NULL, verbose = getOption("verbose"))codocClasses(package, lib.loc = NULL)codocData(package, lib.loc = NULL)}\description{Find inconsistencies between actual and documented \sQuote{structure}of \R objects in a package. \code{codoc} compares names andoptionally also corresponding positions and default values of thearguments of functions. \code{codocClasses} and \code{codocData}compare slot names of S4 classes and variable names of data sets,respectively.}\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 tosearch for \code{package}.}\item{use.values}{if \code{FALSE}, do not use function default valueswhen comparing code and docs. Otherwise, compare \emph{all} defaultvalues if \code{TRUE}, and only the ones documented in the usageotherwise (default).}\item{verbose}{a logical. If \code{TRUE}, additional diagnostics areprinted.}}\note{The default for \code{use.values} has been changed from\code{FALSE} to \code{NULL}, for \R versions 1.9.0 and later.}\details{The purpose of \code{codoc} 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 \pkg{base} package), after possiblydetaching an already loaded version of the package. Otherwise, if thesources are used, the \R code files of the package are collected andsourced in a new environment. Then, the usage sections of the Rdfiles are extracted and parsed \sQuote{as much as possible} to givethe formals documented. For interpreted functions in the codeenvironment, the formals are compared between code and documentationaccording to the values of the argument \code{use.values}. Synopsissections are used if present; their occurrence is reported if\code{verbose} is true.If a package has a name space both exported and unexported objects arechecked, as well as registered S3 methods. (In the unlikely event ofdifferences the order is exported objects in the package, registeredS3 methods and finally objects in the name space and only the firstfound is checked.)Currently, the R documentation format has no high-level markup for thebasic \sQuote{structure} of classes and data sets (similar to the usagesections for function synopses). Variable names for data frames indocumentation objects obtained by suitably editing \sQuote{templates}created by \code{\link{prompt}} are recognized by \code{codocData}and used provided that the documentation object is for a single dataframe (i.e., only has one alias). \code{codocClasses} analogouslyhandles slot names for classes in documentation objects obtained byediting shells created by \code{\link{promptClass}}.Help files named \file{\var{pkgname}-defunct.Rd} for theappropriate \var{pkgname} are checked more loosely, as they mayhave undocumented arguments.}\value{\code{codoc} returns an object of class \code{"codoc"}. Currently,this is a list which, for each Rd object in the package where aninconsistency was found, contains an element with a list of themismatches (which in turn are lists with elements \code{code} and\code{docs}, giving the corresponding arguments obtained from thefunction's code and documented usage).\code{codocClasses} and \code{codocData} return objects of class\code{"codocClasses"} and \code{"codocData"}, respectively, with astructure similar to class \code{"codoc"}.There are \code{print} methods for nicely displaying the informationcontained in such objects.}\seealso{\code{\link{undoc}}, \code{\link{QC}}}\keyword{documentation}