-
Notifications
You must be signed in to change notification settings - Fork 65
/
.brewer.R
35 lines (32 loc) · 1.58 KB
/
.brewer.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
## generate README from the brew file
print(getwd())
library(pander);
detach('package:pander', unload = TRUE);
library(pander)
evalsOptions('graph.unify', TRUE)
## hardcoded plot name for the README
evalsOptions('graph.name', 'plot-1')
## brew the file to another directory (dedicated to the gh-pages branch)
Pandoc.brew('../inst/README.brew', output = 'index', convert = 'html', open = FALSE, portable.html = FALSE)
## fix img and js/css absolute path
t <- readLines('index.html')
t <- gsub('/usr/lib/R/library/pander/includes//', '', t, fixed = TRUE)
t <- gsub('/usr/local/lib/R/site-library/pander/includes//', '', t, fixed = TRUE)
t <- gsub('/home/travis/R/Library/pander/includes//', '', t, fixed = TRUE)
t <- gsub('/Library/Frameworks/R.framework/Versions/3.2/Resources/library/pander/includes//', '', t, fixed = TRUE)
cat(t, file = 'index.html', sep = '\n')
## add README to the pkg (not only to the gh-pages branch)
file.copy('index', 'README.md', overwrite = TRUE)
file.remove('index')
files_to_remove <- setdiff(list.files('plots/', full.names = TRUE),
list.files('plots/', full.names = TRUE, pattern = "^evals"))
file.remove(files_to_remove)
examples <- gsub("(.*)\\.brew$", "\\1", list.files("../inst/examples/"))
for (example in examples) {
brew_path <- file.path("../inst/examples/", paste(example, ".brew", sep=""))
Pandoc.brew(brew_path, output = example, convert = 'html', open = FALSE)
for (format in c('pdf', 'docx', 'odt')) {
try(Pandoc.convert(example, format = format, open = FALSE))
}
file.rename(example, paste(example, ".md", sep=""))
}