forked from TortoiseGit/TortoiseGit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.build
570 lines (460 loc) · 22.1 KB
/
doc.build
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
<?xml version="1.0"?>
<!--
============================================================
$Date: 2008-12-14 09:06:16 +0800 (Sun, 14 Dec 2008) $
$Author: simonlarge $
$Rev: 14835 $
============================================================
NAnt build script for the TortoiseGit documentation
All project specific configuration is stored in doc.build.include.
All user/site specific configuration is stored in doc.build.user.
-->
<project name="Documentation" default="all" basedir=".">
<description>
Builds the Documentation in all languages and all output formats
</description>
<!-- default: we don't clean first -->
<property name="cleanup" value="" overwrite="false" />
<include buildfile="doc.build.include"/>
<!-- ====================================================================== -->
<!-- Loop over all languages -->
<!-- ====================================================================== -->
<target name="all"
description="Loop over all languages, output formats and applications and build documentation"
depends="prepare" >
<foreach item="String" in="${languages}" delim="," property="lang.target">
<!-- language code for English (US) (default)-->
<property name="lang.target.code" value="1033" />
<property name="languagebuildfile" value="${path.user.xsl}/${lang.target}/lang.build" />
<if test="${file::exists(languagebuildfile)}" >
<include buildfile="${languagebuildfile}" />
</if>
<call target="doit" failonerror="${critical or lang.base==lang.target}"/>
</foreach>
</target>
<!-- ====================================================================== -->
<!-- Loop over all applications and output formats -->
<!-- ====================================================================== -->
<target name="doit">
<foreach item="String" in="${applications}" delim="," property="app">
<property name="doc.source.file" value="source/${lang.base}/${app}.xml"/>
<property name="doc.base.name" value="${app}_${lang.base}"/>
<property name="doc.base.work" value="output/${doc.base.name}"/>
<property name="doc.target.name" value="${app}_${lang.target}"/>
<property name="doc.target.work" value="output/${doc.target.name}"/>
<property name="doc.target.source" value="source/${lang.target}/${app}/${app}.xml"/>
<property name="pofiletotranslate" value="po/${app}_${lang.target}.po" />
<echo message="------------------------------------------------------------"/>
<echo message="Creating '${doc.target.name}' documentation"/>
<if test="${file::exists(pofiletotranslate)}" >
<call target="translate" unless="${lang.base==lang.target}" />
</if>
<if test="${lang.base==lang.target or file::exists(pofiletotranslate)}" >
<!-- update version info in version.xml -->
<call target="UpdateVersionInfo"/>
<call target="spellcheck" if="${property::exists('spellcheck') and spellcheck=='true'}"/>
<call target="copyimages"/>
<property name="xslt.source" value="${doc.target.source}"/>
<foreach item="String" in="${docformats}" delim="," property="docformat">
<call target="${docformat}"/>
</foreach>
</if>
</foreach>
</target>
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<target name="clean" description="remove all generated files">
<if test="${cleanup == 'yes'}">
<delete dir="output" failonerror="false"/>
</if>
</target>
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<target name="prepare" description="Create directories" depends="clean">
<mkdir dir="output"/>
<call target="prepare.custom" if="${target::exists('prepare.custom')}"/>
<!-- find the path to the fonts -->
<script language="C#">
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
string linuxPath = "/usr/share/fonts/truetype/";
if (Directory.Exists(linuxPath)) {
project.Properties.Add("fontpath", linuxPath);
return;
}
string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
string fontsPath = Path.GetDirectoryName(systemPath) + Path.DirectorySeparatorChar + "FONTS";
fontsPath = fontsPath.Replace('\\','/');
project.Properties.Add("fontpath", fontsPath );
}
]]>
</code>
</script>
<!-- ensure "Version" translation invariant -->
<copy file="source/${lang.base}/Version.in" tofile="source/${lang.base}/version.xml" overwrite="true"/>
<!-- tune path to xsltproc.exe in aspell.bat -->
<copy file="Aspell/aspell.in" tofile="Aspell/aspell.bat" overwrite="true">
<filterchain>
<replacetokens begintoken="$" endtoken="$">
<token key="XSLTProcPath" value="${path.bin}" />
</replacetokens>
</filterchain>
</copy>
</target>
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<target name="copyimages" description="Copy images">
<delete dir="${doc.target.work}/images" failonerror="false"/>
<mkdir dir="${doc.target.work}/images"/>
<mkdir dir="${doc.target.work}/images/callouts"/>
<copy todir="${doc.target.work}/images">
<fileset basedir="images/${lang.base}">
<include name="*"/>
</fileset>
</copy>
<copy todir="${doc.target.work}/images/callouts">
<fileset basedir="images/${lang.base}/callouts">
<include name="*"/>
</fileset>
</copy>
<copy todir="${doc.target.work}/images" unless="${lang.base==lang.target}" overwrite="true">
<fileset basedir="images/${lang.target}">
<include name="*"/>
</fileset>
</copy>
</target>
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<target name="uptodate" description="Check whether the given target is up to date">
<echo message="Checking if '${file.target}' is up to date"/>
<uptodate property="file.target.uptodate">
<sourcefiles>
<include name="source/${lang.target}/${app}/**/*.xml"/>
<include name="source/${lang.target}/glossary.xml"/>
<include name="source/${lang.target}/wishlist.xml"/>
<include name="source/${lang.target}/version.in"/>
</sourcefiles>
<targetfiles>
<include name="${file.target}"/>
</targetfiles>
</uptodate>
<if test="${file.target.uptodate}">
<echo message="Up to date"/>
</if>
</target>
<!-- ====================================================================== -->
<!-- Run xsltproc with the defined parameters -->
<!-- ====================================================================== -->
<target name="xsltproc" description="Run xsltproc with the defined parameters">
<echo message="Processing XML Source" />
<!-- Check whether a language specific xsl file exists and use it -->
<!-- if none is found, load XSL file from default location. -->
<property name="xslt.file.lang" value="${path.user.xsl}/${lang.target}/${xslt.file}" />
<property name="xslt.file" value="${xslt.file.lang}" if="${file::exists(xslt.file.lang)}"/>
<property name="xslt.file" value="${path.user.xsl}/${xslt.file}" unless="${file::exists(xslt.file.lang)}"/>
<echo message="Stylesheet: ${xslt.file}" />
<echo message="Parameters: ${xslt.params}" />
<exec program="xsltproc"
commandline="${xslt.params} --output ${xslt.target} ${xslt.file} ${xslt.source}"
basedir="${path.bin}"
verbose="false"/>
</target>
<!-- ====================================================================== -->
<!-- Profile source into a single file -->
<!-- ====================================================================== -->
<target name="profile" description="Profile source into a single file" >
<call target="uptodate"/>
<if test="${not file.target.uptodate}">
<property name="xslt.params" value="${xsl.profile.params}"/>
<property name="xslt.file" value="${xsl.profile.file}"/>
<property name="xslt.target" value="${file.target}.tmp"/>
<echo message="Profiling into: ${file.target}"/>
<call target="xsltproc"/>
<!-- Removes the moreinfo="" attributes added by xsltproc -->
<move file="${xslt.target}" tofile="${file.target}" overwrite="true">
<filterchain>
<replacestring from=" moreinfo="none"" to="" />
</filterchain>
</move>
</if>
</target>
<!-- ====================================================================== -->
<!-- Create po template for each application from sources -->
<!-- ====================================================================== -->
<target name="potfile" description="Create po template from sources">
<property name="lang.target" value="${lang.base}"/>
<!-- ensure "Version" translation invariant -->
<copy file="source\${lang.base}\version.in" tofile="source\${lang.base}\version.xml" overwrite="true"/>
<foreach item="String" in="${potemplates}" delim="," property="app">
<property name="potfile" value="po/${app}.pot" />
<property name="xslt.source" value="source/${lang.base}/${app}/${app}.xml"/>
<property name="file.target" value="source/${app}_${lang.base}.xml"/>
<echo message="------------------------------------------------------------"/>
<echo message="Checking if ${potfile} is up to date"/>
<call target="profile" />
<if test="${not file::up-to-date(file.target, potfile)}">
<echo message="Creating po template from sources"/>
<exec program="python"
commandline="xml2po.py -e -o ${potfile}.tmp ${file.target}"
verbose="false"/>
<!-- Adjust path to source file -->
<move file="${potfile}.tmp" tofile="${potfile}" overwrite="true">
<filterchain>
<replacestring from="#: ${file.target}" to="#: ../${file.target}" />
</filterchain>
</move>
</if>
<echo message="" />
</foreach>
</target>
<!-- ====================================================================== -->
<!-- Create translated source files -->
<!-- ====================================================================== -->
<target name="translate" description="Create translated source file">
<property name="lang.pofile" value="po/${app}_${lang.target}.po"/>
<echo message="Translating: '${app} ${lang.target}' This may take a few minutes"/>
<exec program="msgfmt"
commandline="${lang.pofile} -o ${lang.target}.mo"
basedir="${path.gettext}"
verbose="false"/>
<foreach item="File" property="file.base">
<in>
<items>
<include name="source/${lang.base}/${app}/**/*.xml"/>
<include name="source/${lang.base}/glossary.xml"/>
<include name="source/${lang.base}/wishlist.xml"/>
<include name="source/${lang.base}/version.in"/>
</items>
</in>
<do>
<property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
<uptodate property="file.target.uptodate">
<sourcefiles>
<include name="${file.base}"/>
<include name="${lang.pofile}"/>
</sourcefiles>
<targetfiles>
<include name="${file.target}"/>
</targetfiles>
</uptodate>
<if test="${not file.target.uptodate}">
<echo message="Translating: ${path::get-file-name(file.target)}"/>
<property name="dir.target" value="${path::get-directory-name(file.target)}"/>
<mkdir dir="${dir.target}" unless="${directory::exists(dir.target)}"/>
<exec program="python"
commandline='xml2po.py -t "${lang.target}.mo" -o "${file.target}" "${file.base}"'
verbose="false"/>
</if>
</do>
</foreach>
<!--
<foreach item="File" property="file.base">
<in>
<items refid="files.exclude" />
</in>
<do>
<property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
<copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
</do>
</foreach>
-->
<delete file="${lang.target}.mo"/>
</target>
<!-- ====================================================================== -->
<!-- Try to update version info in the version file -->
<!-- ====================================================================== -->
<target name="UpdateVersionInfo" description="Updates the version file with version info">
<copy
file="source/${lang.target}/Version.in"
tofile="source/${lang.target}/version.xml"
overwrite="true">
<filterchain>
<replacetokens begintoken="$" endtoken="$">
<token key="MajorVersion" value="${environment::get-variable('MajorVersion')}"/>
<token key="MinorVersion" value="${environment::get-variable('MinorVersion')}"/>
<token key="MicroVersion" value="${environment::get-variable('MicroVersion')}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<!-- ====================================================================== -->
<!-- Run spellchecker on files -->
<!-- ====================================================================== -->
<target name="spellcheck" description="Run spellchecker on files">
<echo message="Spellchecking: '${app} ${lang.target}' This may take a few minutes"/>
<property name="spellcheck.log" value="ASpell/${app}_${lang.target}.log"/>
<mkdir dir="ASpell/${app}_${lang.target}"/>
<echo message="--- Spellchecking: '${lang.target}'"
file="${spellcheck.log}"
failonerror="false"/>
<copy file="Aspell/TortoiseGit.tmpl.pws" tofile="Aspell/Temp.pws" overwrite="true">
<filterchain>
<replacetokens begintoken="$" endtoken="$">
<token key="LANG" value="${lang.target}" />
</replacetokens>
</filterchain>
</copy>
<foreach item="File" property="file.base">
<in>
<items>
<include name="source/${lang.base}/${app}/**/*.xml"/>
<include name="source/${lang.base}/glossary.xml"/>
<include name="source/${lang.base}/wishlist.xml"/>
</items>
</in>
<do>
<property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
<property name="file.log" value="ASpell\${app}_${lang.target}\${path::get-file-name(file.target)}.log"/>
<uptodate property="file.target.uptodate">
<sourcefiles>
<include name="${file.target}"/>
<include name="ASpell/${lang.target}.pws"/>
<include name="ASpell/TortoiseGit.tmpl.pws"/>
</sourcefiles>
<targetfiles>
<include name="${file.log}"/>
</targetfiles>
</uptodate>
<if test="${not file.target.uptodate}">
<echo message="Checking: ${path::get-file-name(file.target)}"/>
<exec program="Aspell/aspell.bat"
commandline="${path.spellcheck} ${lang.target} ${file.target} ${file.log}"
failonerror="false"/>
</if>
<exec program="Aspell/append.bat"
commandline="${file.log} ${spellcheck.log}"/>
</do>
</foreach>
</target>
<!-- ====================================================================== -->
<!-- Create PDF documentation -->
<!-- ====================================================================== -->
<target name="pdf" description="Create PDF documentation">
<property name="file.target" value="output/${app}-${docverstring}-${lang.target}.pdf"/>
<call target="uptodate"/>
<if test="${not file.target.uptodate}">
<property name="xslt.params" value="${xsl.pdf.params}"/>
<property name="xslt.file" value="${xsl.pdf.file}"/>
<property name="xslt.final" value="${doc.target.work}/${doc.target.name}"/>
<!-- set xslt.target to the name of the temp file -->
<property name="xslt.target" value="${xslt.final}.tmp"/>
<call target="xsltproc" />
<!-- Removes the span="inherit" attribute added by xsltproc, which causes a warning -->
<move file="${xslt.target}" tofile="${xslt.final}.fo" overwrite="true" inputencoding="utf-8" outputencoding="utf-8">
<filterchain>
<replacestring from="span="inherit" " to="" />
<replacestring from="width="auto" height="auto" content-width="auto" content-height="auto"" to="inline-progression-dimension.maximum="100%" content-width="scale-down-to-fit" content-height="scale-down-to-fit"" />
</filterchain>
</move>
<property name="userconfig.langtemplate" value="${path.user.xsl}/${lang.target}/userconfig.template.xml" />
<property name="userconfig.lang" value="${path.user.xsl}/${lang.target}/userconfig.xml" />
<if test="${file::exists(userconfig.langtemplate)}">
<loadfile file="${userconfig.langtemplate}" property="configfile">
<filterchain>
<replacetokens begintoken="%" endtoken="%">
<token key="FONTSDIR" value="${fontpath}" />
</replacetokens>
</filterchain>
</loadfile>
<echo file="${userconfig.lang}" message="${configfile}" />
</if>
<property name="commandline" value="-q -fo ${xslt.final}.fo -pdf ${file.target}"/>
<property name="commandline" value="-c ${userconfig.lang} ${commandline}" if="${file::exists(userconfig.lang)}"/>
<exec program="${name.fop}"
commandline="${commandline}"
basedir="${path.fop}"
verbose="false"/>
</if>
</target>
<!-- ====================================================================== -->
<!-- Create CHM documentation -->
<!-- ====================================================================== -->
<target name="chm" description="Create CHM documentation">
<property name="file.target" value="${doc.target.work}.chm"/>
<call target="uptodate"/>
<if test="${not file.target.uptodate}">
<property name="xslt.params" value="${xsl.chm.params}"/>
<property name="xslt.file" value="${xsl.chm.file}"/>
<property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
<call target="xsltproc" />
<!-- The CHM helpcontext target resides in an external build file -->
<call target="help.prepare" if="${target::exists('help.prepare')}"/>
<copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
<exec program="SBAppLocale.exe"
commandline="${lang.target.code} ${path.bin}/hhc.exe ${doc.target.work}/htmlhelp.hhp"
basedir="${path.bin}"
resultproperty="result.hhc"
failonerror="false"
verbose="false"
timeout="600000" />
<copy file="${doc.target.work}/htmlhelp.chm" tofile="${file.target}"/>
</if>
<!--
<delete>
<fileset>
<include name="${doc.target.work}/*.*"/>
</fileset>
</delete>
-->
</target>
<!-- ====================================================================== -->
<!-- Create HTML multi page documentation -->
<!-- ====================================================================== -->
<target name="html" description="Create HTML documentation" depends="">
<property name="file.target" value="${doc.target.work}/index.html"/>
<call target="uptodate"/>
<if test="${not file.target.uptodate}">
<property name="xslt.params" value="${xsl.htmlsingle.params}"/>
<property name="xslt.file" value="${xsl.htmlsingle.file}"/>
<property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
<copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
<copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
<call target="xsltproc" />
</if>
</target>
<!-- ====================================================================== -->
<!-- Create HTML single page documentation -->
<!-- ====================================================================== -->
<target name="htmlsingle" description="Create HTML single page documentation" depends="">
<property name="file.target" value="${doc.target.work}/help-onepage.html"/>
<call target="uptodate"/>
<if test="${not file.target.uptodate}">
<property name="xslt.params" value="${xsl.html.params}"/>
<property name="xslt.file" value="${xsl.html.file}"/>
<property name="xslt.target" value="${file.target}"/>
<copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
<copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
<call target="xsltproc" />
</if>
</target>
<!-- ====================================================================== -->
<!-- Create the API documentation -->
<!-- ====================================================================== -->
<target name="apidoc" depends="GitAPIdoc,TortoiseGitAPIdoc" />
<target name="GitAPIdoc">
<loadfile file="API\DoxyfileSVN" property="GitDoxyFile" />
<echo file="Doxyfile" message="${GitDoxyFile}" />
<echo file="Doxyfile" message="HHC_LOCATION=${environment::get-variable('HHLOC')}" append="true" />
<mkdir dir="output" />
<exec program="doxygen.exe">
<arg value="Doxyfile" />
</exec>
<move file="output\doxygen\html\GitAPI.chm" tofile="output\GitAPI.chm" overwrite="true" />
<delete dir="output\doxygen" />
<delete file="Doxyfile" />
</target>
<target name="TortoiseGitAPIdoc">
<loadfile file="API\Doxyfile" property="TortoiseGitDoxyFile" />
<echo file="Doxyfile" message="${TortoiseGitDoxyFile}" />
<echo file="Doxyfile" message="HHC_LOCATION=${environment::get-variable('HHLOC')}" append="true" />
<mkdir dir="output" />
<exec program="doxygen.exe">
<arg value="Doxyfile" />
</exec>
<move file="output\doxygen\html\TortoiseAPI.chm" tofile="output\TortoiseGitAPI.chm" overwrite="true" />
<delete dir="output\doxygen" />
<delete file="Doxyfile" />
</target>
</project>