-
Notifications
You must be signed in to change notification settings - Fork 28
/
build-website.R
executable file
·49 lines (42 loc) · 1.56 KB
/
build-website.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
#!/usr/local/bin/Rscript
# script to rebuild website files
library(rmarkdown)
# pkgdown works from your tree, not from installed versions.
# But rmarkdown::render works with installed versions.
# So:
# install the version you want
# optionally create a branch (website-x.y.z)
# update index.Rhtml appropriately
# run this script
# commit any changes
# optionally checkout master, merge in the new branch (git merge website-x.y.z)
# push to github
pdf_output_formats <- list(
"design-principles.Rmd" = pdf_document(latex_engine = "xelatex"),
"huxreg.Rmd" = pdf_document(latex_engine = "xelatex"),
"huxtable.Rmd" = pdf_document(
latex_engine = "xelatex",
toc = TRUE,
toc_depth = 2
)
)
for (f in list.files("docs", pattern = "*.Rmd", full.names = TRUE)) {
filename <- basename(f)
message("Rendering ", f)
filename_no_ext <- sub("\\.Rmd$", "", filename)
rmarkdown::render(f,
output_format = "html_document",
output_file = paste0(filename_no_ext, "-html"))
rmarkdown::render(f,
output_format = pdf_output_formats[[filename]],
output_file = paste0(filename_no_ext, "-pdf"))
}
setwd('docs')
knitr::knit("index.Rhtml", "index.html")
knitr::knit("themes.Rhtml", "themes-html.html")
setwd('..')
pkgdown::build_reference_index()
pkgdown::build_reference(lazy = FALSE)
pkgdown::build_news()
pkgdown::build_tutorials()
message("Now commit and push to github.")