-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild_vignettes_CRAN.R
61 lines (52 loc) · 1.4 KB
/
build_vignettes_CRAN.R
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Vignette names
vignettes <- list.files('./vignettes', pattern = '.Rmd')
# Generate R script versions of vignettes
purl_vignettes <- function(x) {
# Generate the R script version
knitr::purl(
input = paste0('vignettes/', x),
output = paste0('doc/', sub('.Rmd', '.R', x))
)
# Copy this version to inst/doc
file.copy(
from = paste0('doc/', sub('.Rmd', '.R', x)),
to = paste0('inst/doc/', sub('.Rmd', '.R', x)),
overwrite = TRUE
)
}
# Build vignette htmls
build_vignettes = function(x) {
# Build the vignette html file
devtools::build_rmd(
paste0('vignettes/', x)
)
# Copy the .Rmd to doc
file.copy(
from = paste0('vignettes/', x),
to = paste0('doc/', x),
overwrite = TRUE
)
# Copy the .Rmd to inst/doc
file.copy(
from = paste0('vignettes/', x),
to = paste0('inst/doc/', x),
overwrite = TRUE
)
# Copy the .html to inst/doc
file.copy(
from = sub('.Rmd', '.html', paste0('vignettes/', x)),
to = paste0('inst/doc/', sub('.Rmd', '.html', x)),
overwrite = TRUE
)
# Copy the .html to doc
file.copy(
from = sub('.Rmd', '.html', paste0('vignettes/', x)),
to = paste0('doc/', sub('.Rmd', '.html', x)),
overwrite = TRUE
)
# Remove the .html
file.remove(sub('.Rmd', '.html', paste0('vignettes/', x)))
}
# Apply these functions to all vignette .Rmds
lapply(vignettes, purl_vignettes)
lapply(vignettes, build_vignettes)