repair_docu: Repair and check Rd files

Description Usage Arguments Details Value See Also Examples

View source: R/rd.R

Description

The repair_docu methods repair some sometimes encountered, minor problems in Rd files generated by roxygen2 (but not those related to S4 methods), and run the checks implemented in check_keywords and check_examples.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  repair_docu(x, ...)

  ## S3 method for class 'character'
 repair_docu(x, ignore = NULL,
    drop.internal = FALSE, ...)

  ## S3 method for class 'Rd'
 repair_docu(x, remove.dups = FALSE,
    text.dups = FALSE,
    infile = attr(attr(x, "srcref"), "srcfile")$filename,
    ...)

  check_keywords(x, ...)

  ## S3 method for class 'NULL'
 check_keywords(x, full = FALSE, ...)

  ## S3 method for class 'character'
 check_keywords(x, ...)

  ## S3 method for class 'logical'
 check_keywords(x, ...)

  ## S3 method for class 'Rd'
 check_keywords(x, file = NULL,
    list.only = FALSE, ...)

  check_examples(x, ...)

  ## S3 method for class 'Rd'
 check_examples(x, file = NULL, ...)

Arguments

x

For repair_docu, an object of class ‘Rd’, or name(s) of Rd file(s) or of one to several package directories. See pkg_files for the possible expansion of names.

For check_keywords, an object of class ‘Rd’, vector, or NULL. ‘Rd’ objects are checked as described below. If NULL, the total list of known keywords is returned as character vector, otherwise only those contained in x. If a logical vector, x is used like the ‘full’ argument. If a character vector, used to select the descriptions of certain keywords.

For check_examples, an object of class ‘Rd’.

remove.dups

Logical scalar indicating whether (probably) duplicate links in the seealso section shall be removed.

text.dups

Logical scalar indicating whether duplicate words within text content should be noted.

file

Optional character scalar indicating the name of the file from which the ‘Rd’ object was read. Useful when creating messages describing a problem. See logfile.

infile

Used like the file argument.

full

Logical scalar indicating whether the full content of the ‘KEYWORDS.db’ file should be returned, not just the list of keywords.

drop.internal

Logical scalar indicating whether Rd files whose only keyword is ‘internal’ should be deleted.

list.only

Logical scalar indicating whether the keywords should just be collected, not checked against the database.

...

Optional arguments passed to and from other methods, or between the methods.

ignore

NULL or a character vector of file names (without their directory-name parts) to remove from the result, or a list. Ignored if empty. If a non-empty character vector, matching is done case- insensitively. If a list, used as arguments passed to grep (except for x, value and invert). Enclosing ignore in I() reverts the action.

Details

check_keywords checks keywords in Rd files for their presence, for their occurrence within the list given in the ‘KEYWORDS.db’ file that comes with R, and for fitting to the docType entry of the ‘Rd’ object. The ‘Rd’ method examines the content of Rd files.

In addition to checking that the keywords used are listed in the ‘KEYWORDS.db’ file, it is checked that ‘internal’ is not combined with other keywords, and that docType entries such as ‘class’, ‘data’ or ‘package’ are accompanied by the appropriate keywords.

check_examples does not run the examples, if any, and check their results. It checks presence/absence of examples in Rd files. They should not be present if the list of ‘keywords’ contains ‘internal’. Otherwise they should be present unless docType is ‘class’ or ‘package’.

Value

The ‘Rd’ method of repair_docu returns an object of class ‘Rd’, the character method a list of such objects, invisibly. If drop.internal is TRUE, it returns a logical vector indicating whether it was attempted to remove the file.

check_keywords returns a character vector. As a side effect, problem messages are printed to stderr. See logfile for how to send these messages to a file.

check_examples returns a logical scalar, TRUE if examples are either there and should be there or are missing and should be missing, FALSE otherwise. As a side effect, problem messages are printed to stderr. See logfile for how to send these messages to a file.

See Also

Other rd-functions: repair_S4_docu,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 'Rd' objects
summary(x <- repair_docu(xyplot.docu, remove.dups = TRUE, text.dups = TRUE))
stopifnot(identical(x, xyplot.docu)) # nothing to repair here
(x <- check_keywords(xyplot.docu))
stopifnot(identical(x, "hplot"))
(x <- check_examples(xyplot.docu))
stopifnot(x)

# Character data, or zero arguments
(x <- check_keywords())
stopifnot(length(x) > 1, is.character(x), is.null(names(x)))
(x <- check_keywords(c("aplot", "loess")))
stopifnot(length(x) == 2, is.character(x), names(x) == c("aplot", "loess"))

pkgutils documentation built on May 2, 2019, 5:49 p.m.