-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
37 lines (28 loc) · 1.04 KB
/
Makefile
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
SOURCES := $(wildcard *.Rmd)
FILES = $(SOURCES:%.Rmd=docs/%_files) $(SOURCES:%.Rmd=docs/pdf/%_files)
CACHE = $(SOURCES:%.Rmd=%_cache) $(SOURCES:%.Rmd=%_files)
HTMLS = $(SOURCES:%.Rmd=docs/%.html)
RS = $(SOURCES:%.Rmd=docs/R/%.R)
PDFS = $(SOURCES:%.Rmd=docs/pdf/%.pdf)
PDFSTYLE = "rmarkdown::pdf_document"
.PHONY: all clean
all: main clean
main: $(HTMLS) $(RS) $(PDFS)
docs/%.html: %.Rmd _site.yml
@echo "$< -> $@"
@R --vanilla -e "rmarkdown::render_site('$<', envir=new.env())" -e "if('FLash' %in% loadedNamespaces()) detach(package:FLash)"
docs/pdf/%.pdf: %.Rmd
@echo "$< -> $@"
@R --vanilla -e "knitr::opts_chunk[['set']](dev = 'pdf')" -e "rmarkdown::render('$<', output_format='$(PDFSTYLE)', output_file='$@', clean=TRUE)"
docs/R/%.R: %.Rmd
@echo "$< -> $@"
@R --vanilla -e "knitr::purl('$<', output='$@')"
setup:
R -e "install.packages(c('captioner', 'printr', 'rmarkdown', 'knitr'))"
clean:
rm -f *.html
rm -rf $(CACHE)
rm -f docs/R/ini.R
rm -f docs/README docs/index.md docs/Makefile
cleanall: clean
rm -rf $(FILES) $(HTMLS) $(RS) $(PDFS)