The R Project SVN R

Rev

Rev 80015 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
80007 hornik 1
require("tools")
2
 
80009 hornik 3
x <- Rd_db("base")
75574 maechler 4
system.time(y <- lapply(x, function(e)
80009 hornik 5
    tryCatch(Rd2HTML(e, out = nullfile()), error = identity))) # 3-5 sec
75574 maechler 6
stopifnot(!vapply(y, inherits, NA, "error"))
7
## Gave error when "running" \Sexpr{.} DateTimeClasses.Rd
80007 hornik 8
 
9
 
10
## PR#18052: \dots must not be interpreted inside \preformatted
11
Rdsnippet <- tempfile()
12
writeLines(r"(\preformatted{
13
\item{\dots}{foo(arg = "\\\\dots", ...)}
14
})", Rdsnippet)
15
#file.show(Rdsnippet)
16
stopifnot(exprs = {
17
    identical(capture.output(Rd2HTML(Rdsnippet, fragment = TRUE))[2L],
18
              r"(\item{\dots}{foo(arg = "\\dots", ...)})")
19
    identical(capture.output(Rd2txt(Rdsnippet, fragment = TRUE))[2L],
20
              r"(\item{\dots}{foo(arg = "\\dots", ...)})")
21
    identical(capture.output(Rd2latex(Rdsnippet, fragment = TRUE))[2L],
22
              r"(\bsl{}item\{\bsl{}dots\}\{foo(arg = "\bsl{}\bsl{}dots", ...)\})")
23
}) # the last two failed in R < 4.1.0
24
 
25
## also do not translate \dots in R code lines in \examples
26
Rdsnippet <- tempfile()
27
writeLines(r"(\examples{
28
foo <- function(arg = "\\\\dots", ...) NULL # \dots
29
})", Rdsnippet)
30
#file.show(Rdsnippet)
31
stopifnot(exprs = {
32
    identical(capture.output(Rd2ex(parse_Rd(Rdsnippet), fragment = TRUE))[5L],
33
              r"(foo <- function(arg = "\\dots", ...) NULL # \dots)")
34
}) # failed in R < 4.1.0
80015 hornik 35
 
36
## \usage: keep quoted "\\\\dots", but _do_ translate formal \dots arg
37
Rdsnippet <- tempfile()
38
writeLines(r"(\name{foo}\title{foo}\usage{
81836 deepayan 39
## keep this comment to ensure a newline at the end
80015 hornik 40
foo(arg = "\\\\dots", \dots)
41
})", Rdsnippet)
42
Rdobj <- parse_Rd(Rdsnippet)
43
check_dots_usage <- function(FUN) {
44
    out <- trimws(grep("foo(", capture.output(FUN(Rdobj)),
45
                       value = TRUE, fixed = TRUE))
46
    if (!identical(out, r"(foo(arg = "\\dots", ...))"))
47
        stop("unexpected output: ", out)
48
}
49
check_dots_usage(Rd2HTML)
50
check_dots_usage(Rd2txt)
51
check_dots_usage(Rd2latex)
52
## the last two failed in R < 4.1.0; output was foo(arg = "\...", ...)