-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_webpage.R
55 lines (42 loc) · 1.6 KB
/
update_webpage.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
require(pkgdown)
orig_dir <- getwd()
# Rename current docs dir
file.rename("docs", "docs_old")
# Get path to lgpr (and new docs and tutorials)
lgpr_dir <- "../lgpr/"
doc_dir <- file.path(lgpr_dir, "docs")
tut_dir <- file.path(lgpr_dir, "tutorials")
# Copy docs from lgpr dir
file.copy(doc_dir, ".", recursive = TRUE)
# Copy front page figure
file.copy("docs_old/fig1.png", "docs")
# Create tutorials dir
dir.create("docs/tutorials")
# Copy html there
setwd(tut_dir)
fns <- list.files(pattern = "\\.html$", recursive = TRUE)
setwd(orig_dir)
L <- length(fns)
for (j in seq_len(L)) {
fn <- file.path(lgpr_dir, "tutorials", fns[j])
cat("copying from", fn, "\n")
file.copy(fn, "docs/tutorials")
}
# Edit index.html
create_new_html <- function() {
html_add <- readLines("html_insert.txt")
html_add <- paste(html_add, collapse = "\n")
html_old <- readLines("docs/index.html")
num_lines <- length(html_old)
s1 <- "<p>R-package for interpretable nonparametric modeling of longitudinal data using additive Gaussian processes. Contains functionality for inferring covariate effects and assessing covariate relevances. Various models can be specified using a convenient formula syntax.</p>"
s2 <- "<div id=\"requirements\" class=\"section level2\">"
line1 <- which(html_old == s1)
line2 <- which(html_old == s2)
str1 <- paste(html_old[1:line1], collapse = "\n")
str2 <- paste(html_old[line2:num_lines], collapse = "\n")
html_new <- paste(str1, html_add, str2, sep = "\n")
return(html_new)
}
new_html <- create_new_html()
writeLines(new_html, con = "docs/index.html")
# Remove docs_old after running this