-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.xml
370 lines (335 loc) · 15 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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../../etc/phing-grammar.rng"
type="application/xml"
schematypens="http://relaxng.org/ns/structure/1.0"?>
<!--
* ==============================================================================
* Main Phing build file for DocBook5 version of the Phing manual
*
* Public targets that uses xsltproc processing
* ____________________________________________
* html (default) Produce single page HTML output
* chunk Produce chunked HTML output
* pdf Produce PDF output
* epub Experimental support for EPUB
* validate Validate all DocBook5 sources (requires Jing to be installed)
* clean Remove all generated files
*
* Public targets that needs Saxon 6.5.5 for transformation
* ________________________________________________________
* The following two targets produces versions of the manual that applies
* syntax highlightning to all source listings (XML and PHP). However, this
* requres that Saxon 6.5.5 xsl processor is installed as well as the extra
* jar file xslthl-2.x.x.jar (in the CLASSPATH).
*
* PLEASE NOTE that these two targets uses a utility script "hlsaxon" which
* needs a full path to the DocBook5 stylesheets in the script. This varies
* between setups and needs to be adjusted. Mutatis mutandis.
*
* hlhtml Create HTML version using syntax highlighting
* hlpdf Create PDF version using syntax highlighting
*
* Created: 7 feb 2012
* Author: Johan Persson <[email protected]>
* ==============================================================================
-->
<project name="PhingDocBookGuide" default="all" basedir="."
description="Build script to produce Phing documentation from DocBook5 sources">
<!--
========================================================================================
START OF System paths setting. The follwing properties defines capabilities and paths
for the system this build is running on.
========================================================================================
-->
<property name="output.dir" value="out"/>
<!-- DocBook Grammar. Used when running validation script -->
<property name="docbook.relaxngc" value="/usr/share/xml/docbook/schema/rng/5.0/docbookxi.rnc"/>
<property name="docbook.relaxng" value="/usr/share/xml/docbook/schema/rng/5.0/docbookxi.rng"/>
<!-- Paths to executables needded -->
<property name="xsltproc" value="/usr/bin/xsltproc"/>
<property name="xmllint" value="/usr/bin/xmllint"/>
<property name="fop" value="/usr/bin/fop"/>
<!-- DocBook script to help produce ePub output format -->
<property name="dbtoepub" value="/usr/bin/dbtoepub"/>
<!--
Run the "tidy" program to clean up the produced html.
This is mostly useful when tweaking the styling when the output produced by the
XSL sheets must be studied. Running tidy makes it easier to read the resulting (X)HTML.
-->
<property name="flag.tidy" value="0"/>
<property name="tidy" value="/usr/bin/tidy"/>
<!--
========================================================================================
END OF System paths settings.
Noramlly there should be no need for changes below this line.
========================================================================================
-->
<!-- Name of the master XML file -->
<property name="master.document" value="source/master.xml"/>
<!-- Name of the master XML file without file suffix-->
<property name="master.document.strip" value="source/master"/>
<!-- Base directory for XSL stylesheets processed by xsltproc. No trailing '/' -->
<property name="dbxsl.dir" value="stylesheets/xsl"/>
<!-- Base directory for css stylesheets. No trailing '/' -->
<property name="dbcss.dir" value="stylesheets/css"/>
<!--
Possible CSS stylesheet for use with the HTML output.
NOTE: If you change the name you must also update the corresponding
xsl stylesheet since this name is set as a parameter there to tell which
css file to use
-->
<property name="css.style" value="${dbcss.dir}/book.css"/>
<property name="css.highlight" value="${dbcss.dir}/highlight.css"/>
<!-- Canonical name used to reference the chosen CSS stylesheet from the generated (X)HTML -->
<property name="css.name" value="book.css"/>
<!-- The temporary build directory -->
<property name="tmp.dir" value="./tmp/"/>
<!--
Temporary locations for admonition figures used in FO build. MUST be absolute path!
Also note that this path must match the path given in stylesheets/xsl/fo-common.xsl
-->
<property name="tmp.xslimg.dir" value="/tmp/_tmpxslimg" />
<!-- All source files needed -->
<fileset dir="source" id="sources">
<include name="chapters/*.xml"/>
<include name="appendixes/*.xml"/>
<include name="*.xml"/>
<exclude name="template_for_tasks.xml"/>
</fileset>
<!--
================================================================================
TARGET: Clean
================================================================================
-->
<target name="clean">
<delete quiet="yes" dir="${output.dir}/"/>
<phingcall target="_clean_fo_images"/>
</target>
<!--
================================================================================
TARGET: validate
Use Jing to validate book against DocBook Relax NG
================================================================================
-->
<target name="validate">
<xmllint schema="${docbook.relaxng}" useRNG="true">
<fileset refid="sources"/>
</xmllint>
</target>
<!--
==================================================================
Create necessary output directories for
Parameters:
${dir} String Subdirectory.One of html,hlhtml
==================================================================
-->
<target name="_prepare.output">
<mkdir dir="${output.dir}/${dir}"/>
<mkdir dir="${output.dir}/${dir}/img"/>
<!-- Copy all figures used in the documentation -->
<available file="source/figures" property="figures.exist"/>
<if>
<equals arg1="figures.exist" arg2="true"/>
<then>
<copy todir="${output.dir}/${dir}/figures">
<fileset dir="source/figures">
<include name="*.png"/>
<include name="*.jpg"/>
</fileset>
</copy>
</then>
</if>
<copy todir="${output.dir}/${dir}/img">
<fileset dir="${dbcss.dir}/img">
<include name="*"/>
</fileset>
</copy>
</target>
<!--
================================================================================
For PDF creation FO needs the included admonition images to be available at an
absolute path while the PDF is created. For this we use a temporary dir that
we clean after usage.
================================================================================
-->
<target name="_copy_fo_images">
<mkdir dir="${tmp.xslimg.dir}" />
<mkdir dir="${tmp.xslimg.dir}/images" />
<!-- Copy all admonitions used in FO output -->
<copy todir="${tmp.xslimg.dir}/images">
<fileset dir="stylesheets/xsl/images">
<include name="*.png"/>
<include name="*.svg"/>
</fileset>
</copy>
</target>
<target name="_clean_fo_images">
<delete quiet="yes" dir="${tmp.xslimg.dir}" />
</target>
<!--
================================================================================
Target: _html
Help target for the actual HTML and HTMLFANCY targets
================================================================================
-->
<target name="_html">
<uptodate property="target.uptodate" targetfile="${output.dir}/${outdir}/index.html">
<fileset refid="sources"/>
<fileset dir="${dbxsl.dir}">
<include name="html.xsl"/>
<include name="chunk.xsl"/>
<include name="common.xsl"/>
</fileset>
</uptodate>
<if>
<not>
<isset property="target.uptodate"/>
</not>
<then>
<phingcall target="_prepare.output">
<property name="dir" value="${outdir}"/>
</phingcall>
<copy todir="${output.dir}/${outdir}/img">
<fileset dir="${dbcss.dir}/img">
<include name="*"/>
</fileset>
</copy>
<exec executable="${xsltproc}" logoutput="true" checkreturn="true" passthru="true" dir="./">
<arg line="--xinclude -o '${output.dir}/${outdir}/' ${dbxsl.dir}/${xslformat}.xsl ${master.document}"/>
</exec>
<if>
<equals arg1="${flag.tidy}" arg2="1"/>
<then>
<exec executable="${tidy}" logoutput="true">
<arg line="-m -utf8 ${output.dir}/${outdir}/index.html"/>
</exec>
</then>
</if>
</then>
</if>
<copy file="${cssfile}" tofile="${output.dir}/${outdir}/${css.name}"/>
<touch file="${output.dir}/${outdir}/highlight.css"/>
</target>
<target name="html">
<phingcall target="_html">
<property name="outdir" value="html"/>
<property name="xslformat" value="html"/>
<property name="cssfile" value="${css.style}"/>
</phingcall>
</target>
<target name="chunk">
<phingcall target="_html">
<property name="outdir" value="chunkhtml"/>
<property name="xslformat" value="chunk"/>
<property name="cssfile" value="${css.style}"/>
</phingcall>
</target>
<!--
================================================================================
Target: hlhtml Highlighted HTML
Note: This target will only work with the Saxon 6.5.5 xslt processor
================================================================================
-->
<target name="hlhtml">
<uptodate property="target.uptodate" targetfile="${output.dir}/hlhtml/index.html">
<fileset refid="sources"/>
<fileset dir="${dbxsl.dir}">
<include name="hl-html.xsl"/>
<include name="html-highlight.xsl"/>
<include name="common.xsl"/>
</fileset>
</uptodate>
<if>
<not>
<isset property="target.uptodate"/>
</not>
<then>
<phingcall target="_prepare.output">
<property name="dir" value="hlhtml"/>
</phingcall>
<!-- We first need to flatten the master file since Saxon doesn't handle XInclude -->
<exec executable="${xmllint}" logoutput="true" checkreturn="true">
<arg line="--xinclude ${master.document} > ${output.dir}/hlhtml/_flatten.xml"/>
</exec>
<exec dir="${output.dir}/hlhtml/" executable="${phing.dir}/scripts/hlsaxon" logoutput="true" checkreturn="true">
<arg line="_flatten.xml ${phing.dir}/${dbxsl.dir}/hl-html.xsl"/>
</exec>
<delete file="${output.dir}/hlhtml/_flatten.xml"/>
</then>
</if>
<copy file="${css.style}" todir="${output.dir}/hlhtml"/>
<copy file="${css.highlight}" todir="${output.dir}/hlhtml"/>
</target>
<!--
================================================================================
Target: HLPDF
================================================================================
-->
<target name="hlpdf">
<uptodate property="target.uptodate" targetfile="${output.dir}/hlpdf/manual.pdf">
<fileset refid="sources"/>
<fileset dir="${dbxsl.dir}">
<include name="hl-fo.xsl"/>
<include name="fo-highlight.xsl"/>
<include name="fo-common.xsl"/>
<include name="common.xsl"/>
</fileset>
</uptodate>
<if>
<not>
<isset property="target.uptodate"/>
</not>
<then>
<phingcall target="_copy_fo_images"/>
<mkdir dir="${output.dir}/hlpdf"/>
<exec executable="${xmllint}" logoutput="true" checkreturn="true">
<arg line="--xinclude ${master.document} > ${output.dir}/hlpdf/_flatten.xml"/>
</exec>
<exec dir="${output.dir}/hlpdf/" executable="${phing.dir}/scripts/hlsaxon" logoutput="true" checkreturn="true">
<arg line="-o manual.fo _flatten.xml ${phing.dir}/${dbxsl.dir}/hl-fo.xsl"/>
</exec>
<exec dir="${output.dir}/hlpdf/" executable="${fop}" logoutput="true" checkreturn="true">
<arg line="manual.fo -pdf manual.pdf"/>
</exec>
<delete file="${output.dir}/hlpdf/_flatten.xml"/>
<delete file="${output.dir}/hlpdf/manual.fo"/>
<phingcall target="_clean_fo_images"/>
</then>
</if>
</target>
<!--
================================================================================
Target: EPUB
Note: Experimental support for ePub format. (Basically a zipped HTML with
a XML index file.)
================================================================================
-->
<target name="epub">
<uptodate property="target.uptodate" targetfile="${output.dir}/epub/manual.epub">
<fileset refid="sources"/>
</uptodate>
<if>
<not>
<isset property="target.uptodate"/>
</not>
<then>
<mkdir dir="${output.dir}/epub"/>
<exec executable="${dbtoepub}" logoutput="true" checkreturn="true">
<arg line="-o '${output.dir}/epub/manual.epub' -s ${phing.dir}/${dbxsl.dir}/epub.xsl -c ${phing.dir}/${css.style} ${phing.dir}/${master.document}"/>
</exec>
</then>
</if>
</target>
<!--
================================================================================
Target: ALL
Build all possible versions of the manual (incl. highlighted versions)
================================================================================
-->
<target name="all">
<phingcall target="hlpdf"/>
<phingcall target="hlhtml"/>
<phingcall target="chunk"/>
<phingcall target="epub"/>
</target>
</project>