-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
264 lines (221 loc) · 9.81 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# This makefile handles the document compilation for the review article
#
# The text for the article is specified in markdown, one file per article section.
# The source is revision controlled using git
# The text is compiled using pandoc, and targets in this makefile define the
# dependencies of the generated outputs - so that an edit in a source text will
# trigger the regeneration of the compiled output.
python_launch_cmd=python
# python_launch_cmd=winpty python
###############################################################################
# Gather results of archived analytical runs
###############################################################################
# These targets must authenticate to github nd therefore need an access_token
# which must be stored in an environment variable named "GITHUB_TOKEN"
archived_analyses: downloads/ipni-oa-data.zip downloads/ipni-oa-map-charts-data.zip
downloads/%-data.zip: util/download-artifact.py
mkdir -p downloads
$(python_launch_cmd) util/download-artifact.py $*
downloads/ppp.csl:
mkdir -p downloads
wget --quiet -O $@ https://raw.githubusercontent.com/citation-style-language/styles/master/new-phytologist.csl
data/ipni-oa%.png: downloads/ipni-oa-data.zip
mkdir -p data
unzip -o $^ $@
data/si-%.md: downloads/ipni-oa-data.zip
mkdir -p data
unzip -o $^ $@
data/%.yaml: downloads/ipni-oa-data.zip
mkdir -p data
unzip -o $^ $@
$(python_launch_cmd) util/format-numeric-variables.py $@ $@
data/findability-wcvp%.png: downloads/ipni-oa-map-charts-data.zip
mkdir -p data
unzip -o $^ $@
data/oaratio-wcvp%.png: downloads/ipni-oa-map-charts-data.zip
mkdir -p data
unzip -o $^ $@
data/wcvp-map-composite%.png: downloads/ipni-oa-map-charts-data.zip
mkdir -p data
unzip -o $^ $@
data/taxa2gbif%.yaml: downloads/wcvp-gbif-processing-data.zip
mkdir -p data
unzip -o $^ $@
$(python_launch_cmd) util/format-numeric-variables.py $@ $@
data/taxa2nativerange%.yaml: downloads/wcvp-gbif-processing-data.zip
mkdir -p data
unzip -o $^ $@
$(python_launch_cmd) util/format-numeric-variables.py $@ $@
###############################################################################
# End of archived analytical runs section
###############################################################################
###############################################################################
# Download pandoc reference docx
###############################################################################
downloads/reference.docx:
mkdir -p downloads
pandoc -o $@ --print-default-data-file reference.docx
###############################################################################
# Define URLs and download for pandoc filters
###############################################################################
filter_url_scholarly_metadata=https://raw.githubusercontent.com/pandoc/lua-filters/master/scholarly-metadata/scholarly-metadata.lua
filter_url_author_info_blocks=https://raw.githubusercontent.com/pandoc/lua-filters/master/author-info-blocks/author-info-blocks.lua
pandoc-filters/scholarly-metadata.lua:
mkdir -p pandoc-filters
wget --quiet -O $@ $(filter_url_scholarly_metadata)
pandoc-filters/author-info-blocks.lua:
mkdir -p pandoc-filters
wget --quiet -O $@ $(filter_url_author_info_blocks)
###############################################################################
# End of pandoc filter section
###############################################################################
data/section-separator.md:
mkdir -p data
echo " " > $@
echo "" >> $@
###############################################################################
# Concatenate all source markdown files to a single output
###############################################################################
# Define variable holding all parts of the article, listed in order
article_parts=00-preamble.yaml \
01-summary.md \
data/section-separator.md \
02-keywords.md \
data/section-separator.md \
03-societal_impact_statement.md \
data/section-separator.md \
04-introduction.md \
data/section-separator.md \
05-materials_and_methods.md \
data/section-separator.md \
06-results.md \
data/section-separator.md \
07-discussion.md \
data/section-separator.md \
08-acknowledgements.md \
data/section-separator.md \
09-author_contribution.md \
data/section-separator.md \
10-data_availability_statement.md \
data/section-separator.md \
11-conflict_of_interest_statement.md \
data/section-separator.md \
12-references.md
build/article.md: $(article_parts) data/article-variables.yaml data/taxa2gbiftypeavailability.yaml data/taxa2nativerangetypeavailability.yaml
mkdir -p build
cat $(article_parts) > build/article-temp.md
pandoc --template build/article-temp.md --metadata-file data/article-variables.yaml --metadata-file data/taxa2gbiftypeavailability.yaml --metadata-file data/taxa2nativerangetypeavailability.yaml build/article-temp.md > $@
rm build/article-temp.md
###############################################################################
# End of concatenation section
###############################################################################
###############################################################################
# Copy charts to build directory
###############################################################################
build/%.png: data/%.png
mkdir -p build
cp $^ $@
build/%.md: data/%.md
mkdir -p build
cp $^ $@
ipni_oatrends_charts:=build/ipni-oa-composite.png
ipni_publ_charts:=build/ipni-oatrend-publ-2019-2021.png
ipni_wcvp_map_charts_composite:=build/wcvp-map-composite-level-1.png build/wcvp-map-composite-level-2.png build/wcvp-map-composite-level-3.png
charts=$(ipni_oatrends_charts) $(ipni_publ_charts) $(ipni_wcvp_map_charts_composite)
allcharts: $(charts)
###############################################################################
# End of chart copy section
###############################################################################
###############################################################################
# Build outputs using pandoc with bibliographic processing
###############################################################################
#------------------------------------------------------------------------------
# HTML version
#------------------------------------------------------------------------------
build/article.html: downloads/ppp.csl pandoc-filters/scholarly-metadata.lua pandoc-filters/author-info-blocks.lua build/article.md $(charts) references.bib
mkdir -p build
pandoc \
--lua-filter=pandoc-filters/scholarly-metadata.lua \
--lua-filter=pandoc-filters/author-info-blocks.lua \
-F mermaid-filter \
--filter pandoc-xnos \
--variable=date:"$(date_formatted)" \
--citeproc \
--csl downloads/ppp.csl \
--bibliography references.bib \
-o $@ \
--verbose \
-s \
--resource-path=build \
build/article.md
html: build/article.html
#------------------------------------------------------------------------------
# DOCX version
#------------------------------------------------------------------------------
build/article.docx: downloads/ppp.csl pandoc-filters/scholarly-metadata.lua pandoc-filters/author-info-blocks.lua downloads/reference.docx build/article.md $(charts) references.bib
mkdir -p build
pandoc \
--lua-filter=pandoc-filters/scholarly-metadata.lua \
--lua-filter=pandoc-filters/author-info-blocks.lua \
-F mermaid-filter \
--filter pandoc-xnos \
--variable=date:"$(date_formatted)" \
--citeproc \
--csl downloads/ppp.csl \
--bibliography references.bib \
-o $@ \
--verbose \
-s \
--resource-path=build \
--reference-doc=downloads/reference.docx \
build/article.md
docx: build/article.docx
#------------------------------------------------------------------------------
# PDF version
#------------------------------------------------------------------------------
build/article.pdf: downloads/ppp.csl pandoc-filters/scholarly-metadata.lua pandoc-filters/author-info-blocks.lua build/article.md $(charts) references.bib
mkdir -p build
pandoc --lua-filter=pandoc-filters/scholarly-metadata.lua \
--lua-filter=pandoc-filters/author-info-blocks.lua \
-F mermaid-filter \
--filter pandoc-xnos \
--variable=date:"$(date_formatted)" \
--pdf-engine=lualatex \
--citeproc \
--csl downloads/ppp.csl \
--bibliography references.bib \
-o $@ \
--verbose \
--resource-path=build \
build/article.md
pdf: build/article.pdf
#------------------------------------------------------------------------------
# All versions
#------------------------------------------------------------------------------
all: build/article.html build/article.docx build/article.pdf
###############################################################################
# End of build outputs section
###############################################################################
###############################################################################
# Archive section - zip and timestamp a compilation
###############################################################################
# Formatted date, for use when tagging archived compilations
date_formatted=$(shell date +"%d %B %Y")
# TODO
###############################################################################
# End of archive section
###############################################################################
###############################################################################
# Targets to handle cleanup of compiled / dpwnloaded files
###############################################################################
clean:
rm -rf build
rm -rf data
sterilise:
rm -rf build
rm -rf data
rm -rf downloads
rm -rf pandoc-filters
###############################################################################
# End of cleanup section
###############################################################################