Fix typo
[TortoiseGit.git] / doc / doc.build
bloba3705cd9da03cafdb4f729e1cb8b6006e2cdfb9f
1 <?xml version="1.0"?>
2 <!--
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.
8 -->
10 <project name="Documentation" default="all" basedir=".">
11 <description>
12 Builds the Documentation in all languages and all output formats
13 </description>
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 <!-- ====================================================================== -->
24 <target name="all"
25 description="Loop over all languages, output formats and applications and build documentation"
26 depends="prepare" >
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}" />
34 </if>
35 <call target="doit" failonerror="${critical or lang.base==lang.target}"/>
36 </foreach>
37 </target>
39 <!-- ====================================================================== -->
40 <!-- Loop over all applications and output formats -->
41 <!-- ====================================================================== -->
43 <target name="doit">
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}" />
60 </if>
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}"/>
71 </foreach>
72 </if>
73 </foreach>
74 </target>
76 <!-- ====================================================================== -->
77 <!-- ====================================================================== -->
79 <target name="clean" description="remove all generated files">
80 <if test="${cleanup == 'yes'}">
81 <delete dir="output" failonerror="false"/>
82 </if>
83 </target>
85 <!-- ====================================================================== -->
86 <!-- ====================================================================== -->
88 <target name="prepare" description="Create directories" depends="clean">
89 <mkdir dir="output"/>
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()}">
101 <filterchain>
102 <replacetokens begintoken="$" endtoken="$">
103 <token key="XSLTProcPath" value="${path.bin}" />
104 </replacetokens>
105 </filterchain>
106 </copy>
108 </target>
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}"
123 verbose="false"/>
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)}"/>
128 </foreach>
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"/>
138 </fileset>
139 </copy>
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'}"/>
145 </fileset>
146 </copy>
147 </target>
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">
156 <sourcefiles>
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"/>
161 </sourcefiles>
162 <targetfiles>
163 <include name="${file.target}"/>
164 </targetfiles>
165 </uptodate>
166 <if test="${file.target.uptodate}">
167 <echo message="Up to date"/>
168 </if>
169 </target>
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}"
191 verbose="false"/>
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>
197 </target>
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">
217 <filterchain>
218 <replacestring from=" moreinfo=&quot;none&quot;" to="" />
219 </filterchain>
220 </move>
221 </if>
222 </target>
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}"
249 verbose="false"/>
251 <!-- Adjust path to source file -->
252 <move file="${potfile}.tmp" tofile="${potfile}" overwrite="true">
253 <filterchain>
254 <replacestring from="#: ${file.target}" to="#: ../${file.target}" />
255 </filterchain>
256 </move>
257 </if>
259 <echo message="" />
260 </foreach>
261 </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}"
275 verbose="false"/>
277 <foreach item="File" property="file.base">
278 <in>
279 <items>
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"/>
284 </items>
285 </in>
286 <do>
287 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
289 <uptodate property="file.target.uptodate">
290 <sourcefiles>
291 <include name="${file.base}"/>
292 <include name="${lang.pofile}"/>
293 </sourcefiles>
294 <targetfiles>
295 <include name="${file.target}"/>
296 </targetfiles>
297 </uptodate>
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}"'
306 verbose="false"/>
307 </if>
309 </do>
310 </foreach>
312 <!--
313 <foreach item="File" property="file.base">
314 <in>
315 <items refid="files.exclude" />
316 </in>
317 <do>
318 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
319 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
320 </do>
321 </foreach>
324 <delete file="${lang.target}.mo"/>
325 </target>
327 <!-- ====================================================================== -->
328 <!-- Try to update version info in the version file -->
329 <!-- ====================================================================== -->
331 <target name="UpdateVersionInfo" description="Updates the version file with version info">
333 <copy
334 file="source/${lang.target}/Version.in"
335 tofile="source/${lang.target}/version.xml"
336 overwrite="true">
338 <filterchain>
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')}"/>
343 </replacetokens>
344 </filterchain>
345 </copy>
347 </target>
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">
363 <filterchain>
364 <replacetokens begintoken="$" endtoken="$">
365 <token key="LANG" value="${lang.target}" />
366 </replacetokens>
367 </filterchain>
368 </copy>
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">
372 <in>
373 <items>
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"/>
378 </items>
379 </in>
380 <do>
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">
385 <sourcefiles>
386 <include name="${file.target}"/>
387 <include name="Aspell/${lang.target}.pws"/>
388 <include name="Aspell/TortoiseGit.tmpl.pws"/>
389 </sourcefiles>
390 <targetfiles>
391 <include name="${file.log}"/>
392 </targetfiles>
393 </uptodate>
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="&quot;${path.spellcheck}&quot; &quot;${lang.target}&quot; &quot;${file.target}&quot; &quot;${file.log}&quot;"
399 failonerror="false"/>
400 </if>
401 <exec program="Aspell/append${script.extension}"
402 commandline="${file.log} ${spellcheck.log}"/>
403 </do>
404 </foreach>
405 </target>
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">
427 <filterchain>
428 <replacestring from="span=&quot;inherit&quot; " to="" />
429 <replacestring from="width=&quot;auto&quot; height=&quot;auto&quot; content-width=&quot;auto&quot; content-height=&quot;auto&quot;" to="inline-progression-dimension.maximum=&quot;100%&quot; content-width=&quot;scale-down-to-fit&quot; content-height=&quot;scale-down-to-fit&quot;" />
430 </filterchain>
431 </move>
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">
438 <filterchain>
439 <replacetokens begintoken="%" endtoken="%">
440 <token key="FONTSDIR" value="${fontpath}" />
441 </replacetokens>
442 </filterchain>
443 </loadfile>
444 <echo file="${userconfig.lang}" message="${configfile}" />
445 </if>
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}"
452 verbose="false"/>
453 </if>
454 </target>
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"
481 failonerror="false"
482 verbose="false"
483 timeout="600000" />
485 <copy file="${doc.target.work}/htmlhelp.chm" tofile="${file.target}"/>
486 </if>
487 <!--
488 <delete>
489 <fileset>
490 <include name="${doc.target.work}/*.*"/>
491 </fileset>
492 </delete>
494 </target>
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" />
514 </if>
515 </target>
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" />
536 </if>
537 </target>
539 </project>