-
Notifications
You must be signed in to change notification settings - Fork 266
/
build.xml
210 lines (188 loc) · 9.73 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
<?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="guidelines.version" value="22" description="Which version of WCAG is being built"/>
<property name="w3ccvs.location" location="../../../w3ccvs"/>
<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.techniques}/index-flat.html" failonerror="false"/>
<delete file="${inputdir.understanding}/index-flat.html" failonerror="false"/>
<delete file="${inputdir.understanding}/about-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.guidelines}/test-sql.sql" failonerror="false"/>
<delete file="${inputdir.techniques}/techniques.xml" failonerror="false"/>
<delete file="${inputdir.techniques}/technique-associations.xml" failonerror="false"/>
<delete file="${inputdir.techniques}/about-flat.html" failonerror="false"/>
<delete file="${inputdir.understanding}/about-flat.html" 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, guidelines-versions" 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/${guidelines.version}"/>
<copy file="css/base.css" todir="output/guidelines/${guidelines.version}"/>
<copy file="guidelines/guidelines.css" todir="output/guidelines/${guidelines.version}"/>
<copy file="guidelines/relative-luminance.html" todir="output/guidelines/${guidelines.version}"/>
<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/${guidelines.version}/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>
<!-- 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>
<!-- Generic JSON -->
<target name="generic-json" depends="init, guidelines-xml">
<xslt in="${inputdir.guidelines}/wcag.xml" out="${inputdir.guidelines}/wcag.json" style="xslt/generic-xml-to-json.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<!-- Redirects -->
<target name="redirects">
<xslt in="xslt/ids.xml" out="output/understanding/.htaccess" style="xslt/ids-to-redirects.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<!-- SQL for CR test tool -->
<target name="cr-sql" depends="guidelines-xml, guidelines-versions, techniques-list, techniques-association">
<xslt in="${inputdir.guidelines}/wcag.xml" out="${inputdir.guidelines}/test-sql.sql" style="xslt/generate-test-sql.xslt" force="true">
<classpath path="${classpath.saxon}"/>
<factory name="${xslt.factory}"/>
</xslt>
</target>
<!-- === Sanity check === -->
<target name="sanity" depends="init" description="Identifies inconsistencies in documents"></target>
</project>