3 NAnt build script for the TortoiseGit documentation
5 All project specific configuration is stored in doc.build.include.
6 All user/site specific configuration is stored in doc.build.user.
10 <project name=
"Documentation" default=
"all" basedir=
".">
12 Builds the Documentation in all languages and all output formats
15 <!-- default: we don't clean first -->
16 <property name=
"cleanup" value=
"" overwrite=
"false" />
18 <include buildfile=
"doc.build.include"/>
20 <!-- ====================================================================== -->
21 <!-- Loop over all languages -->
22 <!-- ====================================================================== -->
25 description=
"Loop over all languages, output formats and applications and build documentation"
28 <foreach item=
"String" in=
"${languages}" delim=
"," property=
"lang.target">
29 <!-- language code for English (US) (default)-->
30 <property name=
"lang.target.code" value=
"1033" />
31 <property name=
"languagebuildfile" value=
"${path.user.xsl}/${lang.target}/lang.build" />
32 <if test=
"${file::exists(languagebuildfile)}" >
33 <include buildfile=
"${languagebuildfile}" />
35 <call target=
"doit" failonerror=
"${critical or lang.base==lang.target}"/>
39 <!-- ====================================================================== -->
40 <!-- Loop over all applications and output formats -->
41 <!-- ====================================================================== -->
45 <foreach item=
"String" in=
"${applications}" delim=
"," property=
"app">
46 <property name=
"doc.source.file" value=
"source/${lang.base}/${app}.xml"/>
47 <property name=
"doc.base.name" value=
"${app}_${lang.base}"/>
48 <property name=
"doc.base.work" value=
"output/${doc.base.name}"/>
50 <property name=
"doc.target.name" value=
"${app}_${lang.target}"/>
51 <property name=
"doc.target.work" value=
"output/${doc.target.name}"/>
52 <property name=
"doc.target.source" value=
"source/${lang.target}/${app}/${app}.xml"/>
53 <property name=
"pofiletotranslate" value=
"po/${app}_${lang.target}.po" />
55 <echo message=
"------------------------------------------------------------"/>
56 <echo message=
"Creating '${doc.target.name}' documentation"/>
58 <if test=
"${file::exists(pofiletotranslate)}" >
59 <call target=
"translate" unless=
"${lang.base==lang.target}" />
61 <if test=
"${lang.base==lang.target or file::exists(pofiletotranslate)}" >
62 <!-- update version info in version.xml -->
63 <call target=
"UpdateVersionInfo"/>
65 <call target=
"spellcheck" if=
"${property::exists('spellcheck') and spellcheck=='true'}"/>
67 <property name=
"xslt.source" value=
"${doc.target.source}"/>
68 <foreach item=
"String" in=
"${docformats}" delim=
"," property=
"docformat">
69 <call target=
"copyimages"/>
70 <call target=
"${docformat}"/>
76 <!-- ====================================================================== -->
77 <!-- ====================================================================== -->
79 <target name=
"clean" description=
"remove all generated files">
80 <if test=
"${cleanup == 'yes'}">
81 <delete dir=
"output" failonerror=
"false"/>
85 <!-- ====================================================================== -->
86 <!-- ====================================================================== -->
88 <target name=
"prepare" description=
"Create directories" depends=
"clean">
90 <call target=
"prepare.custom" if=
"${target::exists('prepare.custom')}"/>
92 <property name=
"fontpath" value=
"/usr/share/fonts/truetype/" if=
"${platform::is-unix() and not property::exists('fontpath')}"/>
93 <property name=
"fontpath" value=
"${string::replace(environment::get-variable('windir'), '\', '/')}/Fonts/" if=
"${platform::is-windows() and not property::exists('fontpath')}"/>
94 <fail unless=
"${directory::exists(fontpath)}">fontpath '${fontpath}' does not exist
</fail>
96 <!-- ensure "Version" translation invariant -->
97 <copy file=
"source/${lang.base}/Version.in" tofile=
"source/${lang.base}/version.xml" overwrite=
"true"/>
99 <!-- tune path to xsltproc.exe in aspell.bat -->
100 <copy file=
"Aspell/aspell.bat.in" tofile=
"Aspell/aspell.bat" overwrite=
"true" unless=
"${platform::is-unix()}">
102 <replacetokens begintoken=
"$" endtoken=
"$">
103 <token key=
"XSLTProcPath" value=
"${path.bin}" />
110 <!-- ====================================================================== -->
111 <!-- ====================================================================== -->
113 <target name=
"copyimages" description=
"Copy images">
114 <delete dir=
"${doc.target.work}/images" failonerror=
"false"/>
115 <mkdir dir=
"${doc.target.work}/images"/>
116 <mkdir dir=
"${doc.target.work}/images/callouts" if=
"${app=='TortoiseGit'}"/>
118 <property name=
"xslt.params" value=
"${xsl.pdf.params}"/>
119 <property name=
"xslt.target" value=
"${path::get-temp-file-name()}"/>
120 <exec program=
"xsltproc"
121 commandline=
"${xslt.params} --output ${xslt.target} images/extract-images.xsl ${xslt.source}"
122 basedir=
"${path.bin}"
124 <foreach item=
"Line" in=
"${xslt.target}" property=
"filename" trim=
"Both">
125 <property name=
"destname" value=
"${doc.target.work}/images/${filename}"/>
126 <copy file=
"images/${lang.target}/${filename}" tofile=
"${destname}" if=
"${file::exists(path::combine('images', path::combine(lang.target, filename)))}"/>
127 <copy file=
"images/${lang.base}/${filename}" tofile=
"${destname}" unless=
"${file::exists(destname)}"/>
130 <copy todir=
"${doc.target.work}/images">
131 <fileset basedir=
"images/${lang.base}">
132 <include name=
"caution.png"/>
133 <include name=
"warning.png"/>
134 <include name=
"important.png"/>
135 <include name=
"tip.png"/>
136 <include name=
"note.png"/>
137 <include name=
"link.png"/>
141 <copy todir=
"${doc.target.work}/images/callouts" if=
"${app=='TortoiseGit'}">
142 <fileset basedir=
"images/${lang.base}/callouts">
143 <include name=
"*.png" unless=
"${docformat=='pdf'}"/>
144 <include name=
"*.svg" if=
"${docformat=='pdf'}"/>
149 <!-- ====================================================================== -->
150 <!-- ====================================================================== -->
152 <target name=
"uptodate" description=
"Check whether the given target is up to date">
154 <echo message=
"Checking if '${file.target}' is up to date"/>
155 <uptodate property=
"file.target.uptodate">
157 <include name=
"source/${lang.target}/${app}/**/*.xml"/>
158 <include name=
"source/${lang.target}/glossary.xml"/>
159 <include name=
"source/${lang.target}/wishlist.xml"/>
160 <include name=
"source/${lang.target}/version.in"/>
163 <include name=
"${file.target}"/>
166 <if test=
"${file.target.uptodate}">
167 <echo message=
"Up to date"/>
171 <!-- ====================================================================== -->
172 <!-- Run xsltproc with the defined parameters -->
173 <!-- ====================================================================== -->
175 <target name=
"xsltproc" description=
"Run xsltproc with the defined parameters">
176 <echo message=
"Processing XML Source" />
178 <!-- Check whether a language specific xsl file exists and use it -->
179 <!-- if none is found, load XSL file from default location. -->
180 <property name=
"xslt.file.lang" value=
"${path.user.xsl}/${lang.target}/${xslt.file}" />
181 <property name=
"xslt.file" value=
"${xslt.file.lang}" if=
"${file::exists(xslt.file.lang)}"/>
182 <property name=
"xslt.file" value=
"${path.user.xsl}/${xslt.file}" unless=
"${file::exists(xslt.file.lang)}"/>
184 <echo message=
"Stylesheet: ${xslt.file}" />
185 <echo message=
"Parameters: ${xslt.params}" />
186 <property name=
"xslt.output.file" value=
"${path::get-temp-file-name()}"/>
187 <exec program=
"xsltproc"
188 commandline=
"${xslt.params} --output ${xslt.target} ${xslt.file} ${xslt.source}"
189 basedir=
"${path.bin}"
190 output=
"${xslt.output.file}"
192 <loadfile file=
"${xslt.output.file}" property=
"xsltproc.output" />
193 <fail if=
"${string::contains(xsltproc.output, ': parser error :')}">"Parser error" found
</fail>
194 <fail if=
"${string::contains(xsltproc.output, 'Error: no ID for constraint linkend:')}">"Error: no ID for constraint linkend:" found
</fail>
195 <fail if=
"${string::contains(xsltproc.output, 'ERROR: xref linking to ')}">"ERROR: xref linking to" found
</fail>
196 <fail if=
"${string::contains(xsltproc.output, ', but no template matches.')}">unknown element found (look for
"Element X encountered in Y, but no template matches.")
</fail>
199 <!-- ====================================================================== -->
200 <!-- Profile source into a single file -->
201 <!-- ====================================================================== -->
203 <target name=
"profile" description=
"Profile source into a single file" >
205 <call target=
"uptodate"/>
207 <if test=
"${not file.target.uptodate}">
208 <property name=
"xslt.params" value=
"${xsl.profile.params}"/>
209 <property name=
"xslt.file" value=
"${xsl.profile.file}"/>
210 <property name=
"xslt.target" value=
"${file.target}.tmp"/>
212 <echo message=
"Profiling into: ${file.target}"/>
213 <call target=
"xsltproc"/>
215 <!-- Removes the moreinfo="" attributes added by xsltproc -->
216 <move file=
"${xslt.target}" tofile=
"${file.target}" overwrite=
"true">
218 <replacestring from=
" moreinfo="none"" to=
"" />
224 <!-- ====================================================================== -->
225 <!-- Create po template for each application from sources -->
226 <!-- ====================================================================== -->
228 <target name=
"potfile" description=
"Create po template from sources">
229 <property name=
"lang.target" value=
"${lang.base}"/>
231 <!-- ensure "Version" translation invariant -->
232 <copy file=
"source\${lang.base}\version.in" tofile=
"source\${lang.base}\version.xml" overwrite=
"true"/>
234 <foreach item=
"String" in=
"${potemplates}" delim=
"," property=
"app">
236 <property name=
"potfile" value=
"po/${app}.pot" />
237 <property name=
"xslt.source" value=
"source/${lang.base}/${app}/${app}.xml"/>
238 <property name=
"file.target" value=
"source/${app}_${lang.base}.xml"/>
240 <echo message=
"------------------------------------------------------------"/>
241 <echo message=
"Checking if ${potfile} is up to date"/>
243 <call target=
"profile" />
245 <if test=
"${not file::up-to-date(file.target, potfile)}">
246 <echo message=
"Creating po template from sources"/>
247 <exec program=
"python"
248 commandline=
"xml2po.py -e -o ${potfile}.tmp ${file.target}"
251 <!-- Adjust path to source file -->
252 <move file=
"${potfile}.tmp" tofile=
"${potfile}" overwrite=
"true">
254 <replacestring from=
"#: ${file.target}" to=
"#: ../${file.target}" />
263 <!-- ====================================================================== -->
264 <!-- Create translated source files -->
265 <!-- ====================================================================== -->
267 <target name=
"translate" description=
"Create translated source file">
268 <property name=
"lang.pofile" value=
"po/${app}_${lang.target}.po"/>
270 <echo message=
"Translating: '${app} ${lang.target}' This may take a few minutes"/>
272 <exec program=
"msgfmt"
273 commandline=
"${lang.pofile} -o ${lang.target}.mo"
274 basedir=
"${path.gettext}"
277 <foreach item=
"File" property=
"file.base">
280 <include name=
"source/${lang.base}/${app}/**/*.xml"/>
281 <include name=
"source/${lang.base}/glossary.xml"/>
282 <include name=
"source/${lang.base}/wishlist.xml"/>
283 <include name=
"source/${lang.base}/version.in"/>
287 <property name=
"file.target" value=
"${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
289 <uptodate property=
"file.target.uptodate">
291 <include name=
"${file.base}"/>
292 <include name=
"${lang.pofile}"/>
295 <include name=
"${file.target}"/>
299 <if test=
"${not file.target.uptodate}">
301 <echo message=
"Translating: ${path::get-file-name(file.target)}"/>
302 <property name=
"dir.target" value=
"${path::get-directory-name(file.target)}"/>
303 <mkdir dir=
"${dir.target}" unless=
"${directory::exists(dir.target)}"/>
304 <exec program=
"python"
305 commandline='xml2po.py -t
"${lang.target}.mo" -o
"${file.target}" "${file.base}"'
313 <foreach item="File" property="file.base">
315 <items refid="files.exclude" />
318 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
319 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
324 <delete file=
"${lang.target}.mo"/>
327 <!-- ====================================================================== -->
328 <!-- Try to update version info in the version file -->
329 <!-- ====================================================================== -->
331 <target name=
"UpdateVersionInfo" description=
"Updates the version file with version info">
334 file=
"source/${lang.target}/Version.in"
335 tofile=
"source/${lang.target}/version.xml"
339 <replacetokens begintoken=
"$" endtoken=
"$">
340 <token key=
"MajorVersion" value=
"${environment::get-variable('MajorVersion')}"/>
341 <token key=
"MinorVersion" value=
"${environment::get-variable('MinorVersion')}"/>
342 <token key=
"MicroVersion" value=
"${environment::get-variable('MicroVersion')}"/>
349 <!-- ====================================================================== -->
350 <!-- Run spellchecker on files -->
351 <!-- ====================================================================== -->
353 <target name=
"spellcheck" description=
"Run spellchecker on files">
354 <echo message=
"Spellchecking: '${app} ${lang.target}' This may take a few minutes"/>
355 <property name=
"spellcheck.log" value=
"Aspell/${app}_${lang.target}.log"/>
356 <property name=
"script.extension" value=
".bat" if=
"${platform::is-windows()}"/>
357 <property name=
"script.extension" value=
".sh" if=
"${platform::is-unix()}"/>
358 <mkdir dir=
"Aspell/${app}_${lang.target}"/>
360 <delete dir=
"${spellcheck.log}" failonerror=
"false"/>
362 <copy file=
"Aspell/TortoiseGit.tmpl.pws" tofile=
"Aspell/Temp.pws" overwrite=
"true" inputencoding=
"utf-8" outputencoding=
"utf-8">
364 <replacetokens begintoken=
"$" endtoken=
"$">
365 <token key=
"LANG" value=
"${lang.target}" />
369 <exec program=
"sed" commandline=
" -i '1s/^\xEF\xBB\xBF//' ./Aspell/Temp.pws" if=
"${platform::is-unix()}"/> <!-- outputencoding="utf-8" inserts BOM, aspell doesn't like that -->
371 <foreach item=
"File" property=
"file.base">
374 <exclude name=
"source/${lang.base}/TortoiseGit/git_doc/*.xml"/>
375 <include name=
"source/${lang.base}/${app}/**/*.xml"/>
376 <include name=
"source/${lang.base}/glossary.xml"/>
377 <include name=
"source/${lang.base}/wishlist.xml"/>
381 <property name=
"file.target" value=
"${string::replace(file.base, '/' + lang.base + '/', '/' + lang.target + '/')}"/>
382 <property name=
"file.log" value=
"Aspell/${app}_${lang.target}/${path::get-file-name(file.target)}.log"/>
384 <uptodate property=
"file.target.uptodate">
386 <include name=
"${file.target}"/>
387 <include name=
"Aspell/${lang.target}.pws"/>
388 <include name=
"Aspell/TortoiseGit.tmpl.pws"/>
391 <include name=
"${file.log}"/>
395 <if test=
"${not file.target.uptodate}">
396 <echo message=
"Checking: ${path::get-file-name(file.target)}"/>
397 <exec program=
"Aspell/aspell${script.extension}"
398 commandline=
""${path.spellcheck}" "${lang.target}" "${file.target}" "${file.log}""
399 failonerror=
"false"/>
401 <exec program=
"Aspell/append${script.extension}"
402 commandline=
"${file.log} ${spellcheck.log}"/>
407 <!-- ====================================================================== -->
408 <!-- Create PDF documentation -->
409 <!-- ====================================================================== -->
411 <target name=
"pdf" description=
"Create PDF documentation">
413 <property name=
"file.target" value=
"output/${app}-${docverstring}-${lang.target}.pdf"/>
414 <call target=
"uptodate"/>
416 <if test=
"${not file.target.uptodate}">
417 <property name=
"xslt.params" value=
"${xsl.pdf.params}"/>
418 <property name=
"xslt.file" value=
"${xsl.pdf.file}"/>
419 <property name=
"xslt.final" value=
"${doc.target.work}/${doc.target.name}"/>
420 <!-- set xslt.target to the name of the temp file -->
421 <property name=
"xslt.target" value=
"${xslt.final}.tmp"/>
423 <call target=
"xsltproc" />
425 <!-- Removes the span="inherit" attribute added by xsltproc, which causes a warning -->
426 <move file=
"${xslt.target}" tofile=
"${xslt.final}.fo" overwrite=
"true" inputencoding=
"utf-8" outputencoding=
"utf-8">
428 <replacestring from=
"span="inherit" " to=
"" />
429 <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"" />
433 <property name=
"userconfig.langtemplate" value=
"${path.user.xsl}/${lang.target}/userconfig.template.xml" />
434 <property name=
"userconfig.lang" value=
"${path.user.xsl}/${lang.target}/userconfig.xml" />
436 <if test=
"${file::exists(userconfig.langtemplate)}">
437 <loadfile file=
"${userconfig.langtemplate}" property=
"configfile">
439 <replacetokens begintoken=
"%" endtoken=
"%">
440 <token key=
"FONTSDIR" value=
"${fontpath}" />
444 <echo file=
"${userconfig.lang}" message=
"${configfile}" />
446 <property name=
"commandline" value=
"-q -fo ${xslt.final}.fo -pdf ${file.target}"/>
447 <property name=
"commandline" value=
"-c ${userconfig.lang} ${commandline}" if=
"${file::exists(userconfig.lang)}"/>
449 <exec program=
"${name.fop}"
450 commandline=
"${commandline}"
451 basedir=
"${path.fop}"
456 <!-- ====================================================================== -->
457 <!-- Create CHM documentation -->
458 <!-- ====================================================================== -->
460 <target name=
"chm" description=
"Create CHM documentation">
462 <property name=
"file.target" value=
"${doc.target.work}.chm"/>
463 <call target=
"uptodate"/>
465 <if test=
"${not file.target.uptodate}">
466 <property name=
"xslt.params" value=
"${xsl.chm.params}"/>
467 <property name=
"xslt.file" value=
"${xsl.chm.file}"/>
468 <property name=
"xslt.target" value=
"${doc.target.work}/${doc.target.name}"/>
470 <call target=
"xsltproc" />
472 <!-- The CHM helpcontext target resides in an external build file -->
473 <call target=
"help.prepare" if=
"${target::exists('help.prepare')}"/>
475 <copy file=
"${path.user.css}/styles_chm.css" todir=
"${doc.target.work}"/>
477 <exec program=
"SBAppLocale.exe"
478 commandline=
"${lang.target.code} ${path.bin}/hhc.exe ${doc.target.work}/htmlhelp.hhp"
479 basedir=
"${path.bin}"
480 resultproperty=
"result.hhc"
485 <copy file=
"${doc.target.work}/htmlhelp.chm" tofile=
"${file.target}"/>
490 <include name="${doc.target.work}/*.*"/>
496 <!-- ====================================================================== -->
497 <!-- Create HTML multi page documentation -->
498 <!-- ====================================================================== -->
499 <target name=
"html" description=
"Create HTML documentation" depends=
"">
501 <property name=
"file.target" value=
"${doc.target.work}/index.html"/>
502 <call target=
"uptodate"/>
504 <if test=
"${not file.target.uptodate}">
505 <property name=
"xslt.params" value=
"${xsl.htmlsingle.params}"/>
506 <property name=
"xslt.file" value=
"${xsl.htmlsingle.file}"/>
507 <property name=
"xslt.target" value=
"${doc.target.work}/${doc.target.name}"/>
509 <copy file=
"${path.user.css}/styles_chm.css" todir=
"${doc.target.work}"/>
510 <copy file=
"${path.user.css}/styles_html.css" todir=
"${doc.target.work}"/>
512 <call target=
"xsltproc" />
517 <!-- ====================================================================== -->
518 <!-- Create HTML single page documentation -->
519 <!-- ====================================================================== -->
521 <target name=
"htmlsingle" description=
"Create HTML single page documentation" depends=
"">
523 <property name=
"file.target" value=
"${doc.target.work}/help-onepage.html"/>
524 <call target=
"uptodate"/>
526 <if test=
"${not file.target.uptodate}">
527 <property name=
"xslt.params" value=
"${xsl.html.params}"/>
528 <property name=
"xslt.file" value=
"${xsl.html.file}"/>
529 <property name=
"xslt.target" value=
"${file.target}"/>
531 <copy file=
"${path.user.css}/styles_chm.css" todir=
"${doc.target.work}"/>
532 <copy file=
"${path.user.css}/styles_html.css" todir=
"${doc.target.work}"/>
534 <call target=
"xsltproc" />