The R Project SVN R

Rev

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

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