-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (63 loc) · 2.64 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
73
74
75
76
77
78
79
80
GUIX:=/usr/local/bin/guix
GUIXTM:=${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm
RSCRIPT=Rscript --vanilla
DATA:=data/extdata/cvc.csv
MANUSCRIPT:=manuscript
SECTIONDIR:=sections
OUTPUTDIR:=output
DISTDIR:=distribute
RMD=$(wildcard $(SECTIONDIR)/*.Rmd)
DATE=$(shell date +'%Y%m%d')
GITHEAD=$(shell git rev-parse --short HEAD)
GITHEADL=$(shell git rev-parse HEAD)
.DELETE_ON_ERROR:
.PHONEY: \
clean clean-dist clean-output \
dist guix-pin-channels \
regenerate-data
all: manuscript
manuscript: $(OUTPUTDIR)/$(MANUSCRIPT).html
$(OUTPUTDIR):
@mkdir -p $(OUTPUTDIR)
$(OUTPUTDIR)/%.html: %.Rmd $(RMD) $(DATA) guix/channels.pinned.scm guix/manifest.scm | $(OUTPUTDIR)
${GUIXTM} -- \
${RSCRIPT} -e "rmarkdown::render('$<', output_dir = '$(OUTPUTDIR)')"
$(OUTPUTDIR)/%.docx: %.Rmd $(RMD) $(DATA) guix/channels.pinned.scm guix/manifest.scm | $(OUTPUTDIR)
${GUIXTM} -- \
${RSCRIPT} -e "rmarkdown::render('$<', output_format = 'bookdown::word_document2', output_dir = '$(OUTPUTDIR)')"
$(DISTDIR):
@mkdir -p $(DISTDIR)
dist: $(OUTPUTDIR)/$(MANUSCRIPT).docx $(OUTPUTDIR)/$(MANUSCRIPT).html | $(DISTDIR)
cp $(OUTPUTDIR)/$(MANUSCRIPT).docx $(DISTDIR)/"$(DATE)_$(GITHEAD)_$(MANUSCRIPT).docx"
cp $(OUTPUTDIR)/$(MANUSCRIPT).html $(DISTDIR)/"$(DATE)_$(GITHEAD)_$(MANUSCRIPT).html"
## manual pinning guix channels to latest commits
guix-pin-channels: FORCE guix/channels.pinned.scm
${GUIX} time-machine --channels=guix/channels.scm -- \
describe -f channels > guix/channels.pinned.scm
FORCE:
guix/channels.pinned.scm: guix/channels.scm
${GUIX} time-machine --channels=guix/channels.scm -- \
describe -f channels > guix/channels.pinned.scm
## data/intdata and data/scripts are not part of the git repository
regenerate-data: \
data/intdata/ZVK-Doku.xlsx \
data/scripts/01-anonymize-and-prepare.R
${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest-data-preparation.scm -- \
Rscript data/scripts/01-anonymize-and-prepare.R
gh-pages: manuscript
git checkout gh-pages
sed 's#</h4>#</h4> \
<div style="background-color: \#ffc107; padding: 10px; text-align: center;"> \
Please find the publication at <strong><a href="https://doi.org/10.1016/j.jclinane.2024.111556">10.1016/j.jclinane.2024.111556</a></strong><br /> \
Manuscript date: $(shell date +"%Y-%m-%d %H:%M"); Version: <a href="https://github.com/umg-minai/crt/commit/$(GITHEADL)">$(GITHEAD)</a> \
</div>#' $(OUTPUTDIR)/$(MANUSCRIPT).html > index.html
git add index.html
git commit -m "chore: update index.html"
git checkout main
clean: clean-dist clean-output
clean-dist:
@rm -rf $(DISTDIR)
clean-output:
@rm -rf $(OUTPUTDIR)