The R Project SVN R

Rev

Rev 56382 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/tools/man/codoc.Rd
2
% Part of the R package, http://www.R-project.org
59039 ripley 3
% Copyright 1995-2009 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
16493 hornik 6
\name{codoc}
56186 murdoch 7
\alias{codoc}
25807 hornik 8
\alias{codocClasses}
9
\alias{codocData}
16493 hornik 10
\alias{print.codoc}
25807 hornik 11
\alias{print.codocClasses}
12
\alias{print.codocData}
16493 hornik 13
\title{Check Code/Documentation Consistency}
14
\usage{
16670 hornik 15
codoc(package, dir, lib.loc = NULL,
26963 hornik 16
      use.values = NULL, verbose = getOption("verbose"))
25807 hornik 17
codocClasses(package, lib.loc = NULL)
18
codocData(package, lib.loc = NULL)
16493 hornik 19
}
20
\description{
42961 ripley 21
  Find inconsistencies between actual and documented \sQuote{structure}
25807 hornik 22
  of \R objects in a package.  \code{codoc} compares names and
23
  optionally also corresponding positions and default values of the
25814 hornik 24
  arguments of functions.  \code{codocClasses} and \code{codocData}
25807 hornik 25
  compare slot names of S4 classes and variable names of data sets,
26
  respectively.
16493 hornik 27
}
28
\arguments{
16572 hornik 29
  \item{package}{a character string naming an installed package.}
16493 hornik 30
  \item{dir}{a character string specifying the path to a package's root
31
    source directory.  This must contain the subdirectories \file{man}
32
    with \R documentation sources (in Rd format) and \file{R} with \R
16572 hornik 33
    code.  Only used if \code{package} is not given.}
16670 hornik 34
  \item{lib.loc}{a character vector of directory names of \R libraries,
35
    or \code{NULL}.  The default value of \code{NULL} corresponds to all
36
    libraries currently known.  The specified library trees are used to
43623 hornik 37
    search for \code{package}.}
26818 maechler 38
  \item{use.values}{if \code{FALSE}, do not use function default values
39
    when comparing code and docs.  Otherwise, compare \emph{all} default
40
    values if \code{TRUE}, and only the ones documented in the usage
41
    otherwise (default).}
16493 hornik 42
  \item{verbose}{a logical.  If \code{TRUE}, additional diagnostics are
43
    printed.}
44
}
26543 maechler 45
\note{
26818 maechler 46
  The default for \code{use.values} has been changed from
47
  \code{FALSE} to \code{NULL}, for \R versions 1.9.0 and later.
26543 maechler 48
}
16493 hornik 49
\details{
25807 hornik 50
  The purpose of \code{codoc} is to check whether the documented usage
16493 hornik 51
  of function objects agrees with their formal arguments as defined in
52
  the \R code.  This is not always straightforward, in particular as the
16572 hornik 53
  usage information for methods to generic functions often employs the
54
  name of the generic rather than the method.
16493 hornik 55
 
16572 hornik 56
  The following algorithm is used.  If an installed package is used, it
43623 hornik 57
  is loaded (unless it is the \pkg{base} package), after possibly
58
  detaching an already loaded version of the package.  Otherwise, if the
59
  sources are used, the \R code files of the package are collected and
60
  sourced in a new environment.  Then, the usage sections of the Rd
61
  files are extracted and parsed \sQuote{as much as possible} to give
62
  the formals documented.  For interpreted functions in the code
63
  environment, the formals are compared between code and documentation
64
  according to the values of the argument \code{use.values}.  Synopsis
65
  sections are used if present; their occurrence is reported if
66
  \code{verbose} is true.
16493 hornik 67
 
56382 murdoch 68
  If a package has a namespace both exported and unexported objects are
30805 ripley 69
  checked, as well as registered S3 methods.  (In the unlikely event of
70
  differences the order is exported objects in the package, registered
56382 murdoch 71
  S3 methods and finally objects in the namespace and only the first
30805 ripley 72
  found is checked.)
73
 
25807 hornik 74
  Currently, the R documentation format has no high-level markup for the
42961 ripley 75
  basic \sQuote{structure} of classes and data sets (similar to the usage
27623 ripley 76
  sections for function synopses).  Variable names for data frames in
42961 ripley 77
  documentation objects obtained by suitably editing \sQuote{templates}
30461 ripley 78
  created by \code{\link{prompt}} are recognized by \code{codocData}
27623 ripley 79
  and used provided that the documentation object is for a single data
80
  frame (i.e., only has one alias).  \code{codocClasses} analogously
81
  handles slot names for classes in documentation objects obtained by
30461 ripley 82
  editing shells created by \code{\link{promptClass}}.
35433 ripley 83
 
43623 hornik 84
  Help files named \file{\var{pkgname}-defunct.Rd} for the
85
  appropriate \var{pkgname} are checked more loosely, as they may
86
  have undocumented arguments.
16493 hornik 87
}
88
\value{
25807 hornik 89
  \code{codoc} returns an object of class \code{"codoc"}.  Currently,
90
  this is a list which, for each Rd object in the package where an
91
  inconsistency was found, contains an element with a list of the
92
  mismatches (which in turn are lists with elements \code{code} and
93
  \code{docs}, giving the corresponding arguments obtained from the
94
  function's code and documented usage).
18642 hornik 95
 
25807 hornik 96
  \code{codocClasses} and \code{codocData} return objects of class
97
  \code{"codocClasses"} and \code{"codocData"}, respectively, with a
98
  structure similar to class \code{"codoc"}.
99
 
100
  There are \code{print} methods for nicely displaying the information
18642 hornik 101
  contained in such objects.
16493 hornik 102
}
103
\seealso{
31146 hornik 104
  \code{\link{undoc}}, \code{\link{QC}}
16493 hornik 105
}
106
\keyword{documentation}