-
Notifications
You must be signed in to change notification settings - Fork 26
/
MakeFile.R
129 lines (109 loc) · 3.28 KB
/
MakeFile.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
library(knitr)
library(dplyr)
library(magrittr)
library(glue)
options(
width = 250,
scipen = 100,
max.print = 5000,
stringsAsFactors = FALSE
)
knitr::opts_chunk$set(
echo = TRUE,
comment = NA,
cache = FALSE,
message = FALSE,
warning = FALSE,
dpi = 144
)
## generate (updated) html and md files
# docs_path <- rstudioapi::getActiveProject()
# setwd(docs_path)
docs_path <- setwd(".")
if (basename(getwd()) != "docs") stop("Wrong working directory set")
# docs_path <- setwd("~/gh/docs")
system("make")
knit_docs <- function(x) {
setwd(file.path(docs_path, x, "app"))
list.files(pattern = "*.Rmd") %>% sapply(knit)
setwd(file.path("../..", x))
system("make")
}
sapply(
c("data", "design", "basics", "model", "multivariate"),
knit_docs
)
## setup articles for pkgdown
setwd(docs_path)
make_content <- function(files, app) {
for (file in files) {
article <- readLines(file.path(glue("{app}/app"), file), warn = FALSE)
figs <- ifelse(app == "data", "figures", glue("figures_{app}"))
article <- gsub(figs, glue("https://radiant-rstats.github.io/docs/{app}/{figs}/"), article)
file <- paste0("_", sub("\\.md$", ".Rmd", file))
cat(article, file = file.path(glue("../radiant.{app}/vignettes/pkgdown/{file}")), sep = "\n")
}
}
files <- c(
"combine.Rmd", "explore.md", "manage.md", "pivotr.md",
"report_r.md", "report_rmd.md", "state.md", "transform.Rmd",
"view.Rmd", "visualize.md"
)
make_content(files, "data")
files <- c(
"doe.md", "sample_size.Rmd", "sample_size_comp.Rmd", "sampling.md", "randomizer.md"
)
make_content(files, "design")
files <- c(
"clt.md", "compare_means.md", "compare_props.md", "correlation.md",
"cross_tabs.md", "goodness.md", "prob_calc.Rmd", "single_mean.md",
"single_prop.md"
)
make_content(files, "basics")
files <- c(
"crs.md", "crtree.md", "dtree.Rmd", "evalbin.md",
"evalreg.md", "logistic.Rmd", "mnl.Rmd", "nb.md", "nn.md",
"gbt.md", "rforest.md", "regress.Rmd", "simulater.Rmd"
)
make_content(files, "model")
files <- c(
"conjoint.md", "full_factor.md", "hclus.md", "kclus.md",
"mds.md", "pre_factor.md", "prmap.md"
)
make_content(files, "multivariate")
## making the README.md file after clean-up
setwd(docs_path)
knit("README.Rmd")
setwd(file.path(docs_path, "sub"))
knit("README_dev.Rmd")
knit("tutorials_dev.Rmd")
file.copy(
"README_dev.md",
file.path("../../radiant.data/inst/app/tools/app/about.md"),
overwrite = TRUE
)
file.copy(
"tutorials_dev.md",
file.path("../../radiant.data/inst/app/tools/app/tutorials.md"),
overwrite = TRUE
)
copy_docs <- function(app) {
readLines("README_dev.md", warn = FALSE) %>%
paste0(., collapse = "\n") %>%
sub("radiant.png", paste0(app, ".png"), .) %>%
sub("radiant-rstats/radiant)", paste0("radiant-rstats/", app, ")"), ., fixed = TRUE) %>%
sub("badges/version/radiant)", paste0("badges/version/", app, ")"), ., fixed = TRUE) %>%
sub("package=radiant)", paste0("package=", app, ")"), ., fixed = TRUE) %>%
sub("radiant/issues", paste0(app, "/issues"), ., fixed = TRUE) %>%
cat(file = file.path("../..", app, "README.md"))
}
sapply(
c(
"radiant", "radiant.data", "radiant.design",
"radiant.basics", "radiant.model", "radiant.multivariate"
),
copy_docs
)
## sync (R)md files to gh/radiant
setwd(docs_path)
system("sh rsync_docs2app.sh")