-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
354 lines (322 loc) · 17.3 KB
/
build.xml
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a build file for Apache ant (http://ant.apache.org/). This has been tested with Ant 1.7. -->
<project name="wcag" basedir="." default="usage">
<description>Generate WCAG 2.1 and related documents</description>
<!-- Load overriding properties -->
<xmlproperty file="build.properties" keeproot="false" semanticattributes="true"/>
<!-- The following properties need to be set appropriately before doing a build - they should all be overridden by the above property file, but are kept here to serve as defaults -->
<property name="outputdir" location="." description="Directory within which the output folders are created, normally "../YYYY" unless doing TR in which case it is "../../../TR/<YYYY>""/>
<property name="uri.prefix" value="file:///" description="Prefix if any that must be prepended to URIs to make it resolve on the platform"/>
<property name="xslt.factory" value="net.sf.saxon.TransformerFactoryImpl" description="Class name of the XSLT transformer factory, which sets which XSLT engine to use; must be an XSLT 2.0 processor"/>
<property name="classpath.saxon" value="lib/saxon9he.jar" description="Path to Saxon jar in order to run XSLT 2.0"/>
<!-- The following properties usually do not need to be adjusted -->
<property name="inputdir.guidelines" location="guidelines"/>
<property name="inputdir.understanding" location="understanding"/>
<property name="inputdir.techniques" location="techniques"/>
<property name="outputdir.guidelines" location="${outputdir}/guidelines"/>
<property name="outputdir.understanding" location="${outputdir}/understanding"/>
<property name="outputdir.techniques" location="${outputdir}/techniques"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="lib/ant-contrib-0.6.jar" />
</classpath>
</taskdef>
<target name="usage">
<echo level="info">Usage: "ant <target>" to execute a build task
Enter "ant -projecthelp" to get list of available build tasks</echo>
</target>
<target name="init"></target>
<target name="clean" description="Clean up any temp files">
<delete file="${inputdir.guidelines}/index-flat.html" failonerror="false"/>
<delete file="${inputdir.guidelines}/wcag.xml" failonerror="false"/>
<delete file="${inputdir.guidelines}/wcag.json" failonerror="false"/>
<delete file="${inputdir.guidelines}/versions.xml" failonerror="false"/>
<delete file="${inputdir.techniques}/techniques.xml" failonerror="false"/>
<delete file="${inputdir.techniques}/technique-associations.xml" failonerror="false"/>
<delete file="output.html" failonerror="false"/>
<delete dir="output" failonerror="false"/>
<delete dir="input" failonerror="false"/>
</target>
<target name="flatten" depends="init" description="Build a copy of guidelines with all data-include files incorporated">
<makeurl file="${basedir}/guidelines/" property="base.guidelines"/>
<xslt in="${inputdir.guidelines}/index.html" out="${inputdir.guidelines}/index-flat.html" style="xslt/flatten-document.xslt">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.guidelines}"/>
</xslt>
</target>
<target name="guidelines-xml" depends="flatten" description="Build an XML representation of the guidelines">
<xslt in="${inputdir.guidelines}/index-flat.html" out="${inputdir.guidelines}/wcag.xml" style="xslt/generate-structure-xml.xslt">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<target name="guidelines-versions" description="Create XML list of which WCAG version introduces which guidelines">
<local name="output.file"/>
<property name="output.file" value="${inputdir.guidelines}/versions.xml"/>
<echo file="${output.file}"><![CDATA[<versions>
]]></echo>
<for param="current.dir">
<path><dirset dir="understanding" includes="*"/></path>
<sequential>
<local name="version"/>
<basename file="@{current.dir}" property="version"/>
<echo file="${output.file}" append="yes"><![CDATA[ <version name="${version}">
]]></echo>
<for param="current.file">
<path><fileset dir="@{current.dir}" includes="*"/></path>
<sequential>
<local name="id"/>
<basename file="@{current.file}" property="id" suffix="html"/>
<echo file="${output.file}" append="yes"><![CDATA[ <id id="${id}"/>
]]></echo>
</sequential>
</for>
<echo file="${output.file}" append="yes"><![CDATA[ </version>
]]></echo>
</sequential>
</for>
<echo file="${output.file}" append="yes"><![CDATA[</versions>
]]></echo>
</target>
<target name="guidelines" depends="init">
<mkdir dir="output/guidelines/22"/>
<copy file="guidelines/guidelines.css" todir="output/guidelines/22"/>
<copy file="guidelines/relative-luminance.xml" todir="output/guidelines/22"/>
<exec executable="curl">
<arg value=""https://labs.w3.org/spec-generator/?type=respec&url=https://raw.githack.com/w3c/wcag/master/guidelines/index.html""/>
<arg value="-o"/>
<arg value="output/guidelines/22/index.html"/>
<arg value="-f"/>
<arg value="--retry"/>
<arg value="3"/>
</exec>
</target>
<!-- Techniques -->
<target name="techniques-list" description="Create XML list of all the technique files">
<local name="output.file"/>
<property name="output.file" value="${inputdir.techniques}/techniques.xml"/>
<echo file="${output.file}"><![CDATA[<techniques>
]]></echo>
<for param="current.dir">
<path><dirset dir="techniques" includes="*"/></path>
<sequential>
<local name="technology"/>
<basename file="@{current.dir}" property="technology"/>
<echo file="${output.file}" append="yes"><![CDATA[ <technology name="${technology}">
]]></echo>
<for param="current.file">
<path><fileset dir="@{current.dir}" includes="*"/></path>
<sequential>
<local name="technique"/>
<basename file="@{current.file}" property="technique" suffix="html"/>
<echo file="${output.file}" append="yes"><![CDATA[ <technique id="${technique}">
]]></echo>
<local name="technique.title"/>
<loadfile srcFile="@{current.file}" property="technique.title">
<filterchain>
<linecontainsregexp>
<regexp pattern="</?h1>"/>
</linecontainsregexp>
<striplinebreaks/>
<replaceregex pattern=".*<h1>(.*?)</h1>.*" replace="\1"/>
<replaceregex pattern="\s\s+" replace=" "/>
</filterchain>
</loadfile>
<echo file="${output.file}" append="yes"><![CDATA[ <title>${technique.title}</title>
]]></echo>
<echo file="${output.file}" append="yes"><![CDATA[ </technique>
]]></echo>
</sequential>
</for>
<echo file="${output.file}" append="yes"><![CDATA[ </technology>
]]></echo>
</sequential>
</for>
<echo file="${output.file}" append="yes"><![CDATA[</techniques>
]]></echo>
</target>
<target name="techniques-association" depends="flatten, guidelines-xml, guidelines-versions" description="Build an XML structure of all techniques">
<makeurl file="${basedir}/techniques" property="techniques.dir"/>
<makeurl file="${basedir}/understanding" property="understanding.dir"/>
<xslt in="${inputdir.guidelines}/wcag.xml" out="${inputdir.techniques}/technique-associations.xml" style="xslt/generate-technique-associations.xslt">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="techniques.dir" expression="${techniques.dir}"/>
<param name="understanding.dir" expression="${understanding.dir}"/>
</xslt>
</target>
<target name="techniques" depends="techniques-list, techniques-association, techniques-index">
<makeurl file="${basedir}/techniques/" property="base.techniques"/>
<makeurl file="${basedir}/techniques/technique-associations.xml" property="associations.file"/>
<mkdir dir="${basedir}/output/techniques/"/>
<local name="output.dir"/>
<makeurl file="${basedir}/output/techniques/" property="output.dir"/>
<echo message="Outputting Techniques to ${output.dir}"/>
<xslt in="${inputdir.techniques}/techniques.xml" out="output.html" style="xslt/generate-techniques.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="techniques.dir" expression="${base.techniques}"/>
<param name="associations.file" expression="${associations.file}"/>
<param name="output.dir" expression="${output.dir}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
</xslt>
<copy file="techniques/techniques.css" todir="output/techniques/"/>
<copy file="css/slicenav.css" todir="output/techniques/"/>
<copy todir="output/techniques/">
<fileset dir="techniques" includes="**/img/*"/>
</copy>
</target>
<target name="techniques-toc" depends="techniques-list" description="Generate the TOC for Techniques">
<xslt in="${inputdir.techniques}/techniques.xml" out="techniques/toc.html" style="xslt/generate-techniques-toc.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<target name="techniques-index" depends="techniques-toc" description="Flatten the techniques index file">
<makeurl file="${basedir}/techniques/" property="base.techniques"/>
<mkdir dir="${basedir}/output/techniques/"/>
<xslt in="${inputdir.techniques}/index.html" out="${basedir}/output/techniques/index.html" style="xslt/flatten-document.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.techniques}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
</xslt>
</target>
<!-- Understanding -->
<target name="understanding" depends="guidelines-xml, guidelines-versions, techniques-list, understanding-index" description="Generate formatted Understanding docs">
<makeurl file="${basedir}/understanding/" property="base.understanding"/>
<mkdir dir="${basedir}/output/understanding/"/>
<local name="output.dir"/>
<makeurl file="${basedir}/output/understanding/" property="output.dir"/>
<echo message="Outputting Understanding to ${output.dir}"/>
<xslt in="${inputdir.guidelines}/wcag.xml" out="output.html" style="xslt/generate-understanding.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.understanding}"/>
<param name="output.dir" expression="${output.dir}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
</xslt>
<copy file="understanding/understanding.css" todir="output/understanding/"/>
<copy file="css/slicenav.css" todir="output/understanding/"/>
<copy todir="output/understanding/img/" flatten="true">
<fileset dir="understanding">
<patternset includes="*/img/*"/>
</fileset>
</copy>
</target>
<target name="understanding-toc" depends="guidelines-xml" description="Generate the TOC for Understanding">
<xslt in="${inputdir.guidelines}/wcag.xml" out="understanding/toc.html" style="xslt/generate-understanding-toc.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<target name="understanding-index" depends="understanding-toc" description="Flatten the understanding index file">
<makeurl file="${basedir}/understanding/" property="base.understanding"/>
<mkdir dir="${basedir}/output/understanding/"/>
<xslt in="${inputdir.understanding}/index.html" out="${basedir}/output/understanding/index.html" style="xslt/flatten-document.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.understanding}"/>
<param name="loc.guidelines" expression="https://www.w3.org/TR/WCAG21/" if="publication"/>
<param name="loc.understanding" expression="https://www.w3.org/WAI/WCAG21/Understanding/" if="publication"/>
<param name="loc.techniques" expression="https://www.w3.org/WAI/WCAG21/Techniques/" if="publication"/>
<param name="loc.guidelines" expression="https://w3c.github.io/wcag/guidelines/" if="editors"/>
<param name="loc.understanding" expression="https://w3c.github.io/wcag/understanding/" if="editors"/>
<param name="loc.techniques" expression="https://w3c.github.io/wcag/techniques/" if="editors"/>
</xslt>
</target>
<target name="understanding-flatten" depends="guidelines-xml" description="Generate temp files for Understanding with includes included">
<makeurl file="${basedir}/understanding/" property="base.understanding"/>
<mkdir dir="${basedir}/input/understanding/"/>
<local name="output.dir"/>
<makeurl file="${basedir}/input/understanding/" property="output.dir"/>
<xslt in="${inputdir.guidelines}/wcag.xml" out="output.html" style="xslt/flatten-understanding.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
<param name="base.dir" expression="${base.understanding}"/>
<param name="output.dir" expression="${output.dir}"/>
</xslt>
</target>
<!-- Requirements -->
<target name="requirements" depends="init">
<mkdir dir="output/requirements/22"/>
<exec executable="curl">
<arg value=""https://labs.w3.org/spec-generator/?type=respec&url=https://raw.githack.com/w3c/wcag/master/requirements/22/index.html""/>
<arg value="-o"/>
<arg value="output/requirements/22/index.html"/>
<arg value="-f"/>
<arg value="--retry"/>
<arg value="3"/>
</exec>
</target>
<!-- Conformance Challenges -->
<target name="conformance-challenges" depends="init">
<mkdir dir="output/conformance-challenges"/>
<exec executable="curl">
<arg value=""https://labs.w3.org/spec-generator/?type=respec&url=https://raw.githack.com/w3c/wcag/master/conformance-challenges/index.html""/>
<arg value="-o"/>
<arg value="output/conformance-challenges/index.html"/>
<arg value="-f"/>
<arg value="--retry"/>
<arg value="3"/>
</exec>
</target>
<!-- Publish -->
<target name="deploy" depends="init, understanding-toc, techniques-toc" description="Generate content ready to deploy to gh-pages">
<property name="editors" value="true"/>
<antcall target="guidelines"/>
<antcall target="techniques"/>
<antcall target="understanding"/>
<antcall target="requirements"/>
<antcall target="conformance-challenges"/>
<copy todir="output/working-examples/">
<fileset dir="working-examples/"/>
</copy>
</target>
<target name="publish-w3c" depends="init, understanding-toc, techniques-toc" description="Publish resources to w3c">
<property name="publication" value="true"/>
<antcall target="techniques"/>
<antcall target="understanding"/>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/">
<fileset dir="output/"/>
<globmapper from="*index.html" to="*Overview.html"/>
</copy>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/">
<fileset dir="output" excludes="index.html **/index.html"/>
</copy>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/working-examples/">
<fileset dir="working-examples/"/>
<globmapper from="*index.html" to="*Overview.html"/>
</copy>
<copy todir="../../../smartcvs/WWW/WAI/WCAG21/working-examples/">
<fileset dir="working-examples/" excludes="index.html **/index.html"/>
</copy>
</target>
<!-- JSON -->
<target name="json" depends="init, guidelines-xml, techniques-list, techniques-association">
<xslt in="${inputdir.guidelines}/wcag.xml" out="${inputdir.guidelines}/wcag.json" style="xslt/xml-to-json.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<!-- Everything -->
<target name="all" depends="init, understanding, techniques" description="Generate entire suite"/>
<!-- === Sanity check === -->
<target name="sanity" depends="init" description="Identifies inconsistencies in documents"></target>
</project>