forked from griffinp/r-novice-owls
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (56 loc) · 1.94 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
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
# R Markdown files.
SRC_RMD = $(wildcard ??-*.Rmd)
DST_RMD = $(patsubst %.Rmd,%.md,$(SRC_RMD))
# All Markdown files (hand-written and generated).
ALL_MD = $(wildcard *.md) $(DST_RMD)
EXCLUDE_MD = README.md LAYOUT.md FAQ.md DESIGN.md
SRC_MD = $(filter-out $(EXCLUDE_MD),$(ALL_MD))
DST_HTML = $(patsubst %.md,%.html,$(SRC_MD))
# All outputs.
DST_ALL = $(DST_HTML)
# Pandoc filters.
FILTERS = $(wildcard tools/filters/*.py)
# Inclusions.
INCLUDES = \
-Vheader="$$(cat _includes/header.html)" \
-Vbanner="$$(cat _includes/banner.html)" \
-Vfooter="$$(cat _includes/footer.html)" \
-Vjavascript="$$(cat _includes/javascript.html)"
# Chunk options for knitr (used in R conversion).
R_CHUNK_OPTS = tools/chunk-options.R
# Default action is to show what commands are available.
all : commands
## preview : Build website locally for checking.
preview : $(DST_ALL)
# Pattern for slides (different parameters and template).
motivation.html : motivation.md _layouts/slides.html
pandoc -s -t html \
--template=_layouts/slides \
-o $@ $<
# Pattern to build a generic page.
%.html : %.md _layouts/page.html $(FILTERS)
pandoc -s -t html \
--template=_layouts/page \
--filter=tools/filters/blockquote2div.py \
--filter=tools/filters/id4glossary.py \
$(INCLUDES) \
-o $@ $<
## unittest : Run unit test (for Python 2 and 3)
unittest: tools/check.py tools/validation_helpers.py tools/test_check.py
cd tools/ && python2 test_check.py
cd tools/ && python3 test_check.py
# Pattern to convert R Markdown to Markdown.
%.md: %.Rmd $(R_CHUNK_OPTS)
Rscript -e "knitr::knit('$$(basename $<)', output = '$$(basename $@)')"
## commands : Display available commands.
commands : Makefile
@sed -n 's/^##//p' $<
## settings : Show variables and settings.
settings :
@echo 'SRC_RMD:' $(SRC_RMD)
@echo 'DST_RMD:' $(DST_RMD)
@echo 'SRC_MD:' $(SRC_MD)
@echo 'DST_HTML:' $(DST_HTML)
## clean : Clean up temporary and intermediate files.
clean :
@rm -rf $$(find . -name '*~' -print)