-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (58 loc) · 1.87 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
71
72
R.OPTS := --vanilla
fname := ct-covid
rmd = $(fname).Rmd
source = $(fname).R
date := $(shell date "+%Y%m%d")
.phoney: help html pdf figures html2web publish nocache nopartials noreports clean
## Few targets correspond to files, so, list them here to ensure they always run.
help:
## Print Constants and Targets defined in this Makefile
@echo Constants::
@echo R.OPTS: $(R.OPTS)
@echo fname: $(fname)
@echo rmd: $(rmd)
@echo source: $(source)
@echo outname: $(outname)
@echo date: $(date)
@echo
@echo Targets::
@echo --
@grep -E -A 1 "^[^\# ]+:" Makefile
@echo --
@echo
### building reports
html:
# render html document
R $(R_OPTS) -e "rmarkdown::render('"$(rmd)"', output_format='bookdown::html_document2')"
pdf:
# render pdf document
R $(R_OPTS) -e "rmarkdown::render('"$(rmd)"', output_format='bookdown::pdf_document2')"
figures:
# generate figures only
R $(R_OPTS) -e "base::source('"$(source)"')"
### deploy report to web
html2web:
# make html page suitable for web deployment & put it in '/docs/' folder
sed '/Covid-19 in Connecticut/ r gtag.js' < $(fname).html > tmp0.html ## insert google analytics tag below page title
sed '/Covid-19 in Connecticut/ r html-meta.txt' < tmp0.html > index.html ## insert meta tags below page title
mv --backup index.html ./docs/.
rm -f tmp0.html
publish: html html2web
# stage and commit webpage changes, then push changes to github
git add --verbose 'docs/*'
git add --verbose '03-other-source-data/*'
git commit --verbose -m "update webpage"
git push --verbose --all
### cleaning up
nocache:
# delete cache files
rm -rf $(fname)_cache $(fname)_files
nopartials:
# delete intermediate files
rm -f $(fname).aux $(fname).log $(fname).out
rm -f $(fname).tex $(fname).toc
rm -f $(fname).md $(fname).knit.md $(fname).utf8.md
noreports:
# delete formatted reports
rm -f $(fname).html $(fname).pdf
clean: nocache nopartials noreports