-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompile.R
More file actions
56 lines (39 loc) · 1.88 KB
/
compile.R
File metadata and controls
56 lines (39 loc) · 1.88 KB
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
library(conveniencefunctions)
library(rmarkdown)
rmds <- list.files("rmds/", pattern = "[Rr]md")
htmls <- list.files("html/", "html$")
# unlink("html/steadyStates.html")
# unlink("html/symmtetryDetection.html")
not_yet_rendered <- rmds[!str_detect(rmds, paste0(str_remove_all(htmls, "html"), collapse = "|"))]
# to_render <- rmds
to_render <- not_yet_rendered
# to_render <- "getSymbols.Rmd"
walk(to_render, ~try(rmarkdown::render(file.path("rmds", .x),
output_format = "html_document",
output_file = paste0(str_replace_all(.x, "[Rr]md", "html")),
output_dir = "html")))
# ------------------------------------------------------------- #
# cleanup ----
# ------------------------------------------------------------- #
folders <- list.dirs("rmds/") %>% str_subset("trial")
unlink(folders, recursive = T)
list.files(pattern = "\\.(c|o|so)$", recursive = T) %>% unlink
# ------------------------------------------------------------- #
# commiting ----
# ------------------------------------------------------------- #
system2("git", c("add", "--all"))
git2r::commit(message = "updated htmls")
system2("git", "pull")
system2("git", "push")
# ------------------------------------------------------------- #
# index.html ----
# ------------------------------------------------------------- #
htmls2 <- list.files("html/", "html$")
htmls2 %>% paste0("[", ., "]", "(html/", ., ")") %>% paste0(collapse = "\n\n") %>% paste0("\n\n") %>% writeLines("index.md")
system2("pandoc", c("-o index.html", "index.md"))
git2r::add(".", paste0("index.", c("md", "html")))
git2r::commit(message = "update index")
htmls2 %>% paste0("[", ., "]", "(html/", ., ")") %>% paste0(collapse = "\n\n") %>% paste0("\n\n") %>% writeLines("Readme.md")
git2r::add(".", "Readme.md")
git2r::commit(message = "update readme")
system2("git", "push")