Upgrade libgit2
[TortoiseGit.git] / doc / doc.build
blobbe1627ad235e0b46c793aa4948e0dd2dceea82ae
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 <delete file="source/${lang.base}/TortoiseGit/git_doc/git-doc.xml" if="${app=='TortoiseGit'}"/>
59 <copy file="source/${lang.base}/TortoiseGit/git_doc/git-doc.xml.in" tofile="source/${lang.base}/TortoiseGit/git_doc/git-doc.xml" overwrite="true" if="${app=='TortoiseGit' and external.gitdocs=='0'}"/>
61 <if test="${file::exists(pofiletotranslate)}" >
62 <call target="translate" unless="${lang.base==lang.target}" />
63 </if>
64 <if test="${lang.base==lang.target or file::exists(pofiletotranslate)}" >
65 <!-- update version info in version.xml -->
66 <call target="UpdateVersionInfo"/>
68 <call target="spellcheck" if="${property::exists('spellcheck') and spellcheck=='true'}"/>
70 <property name="xslt.source" value="${doc.target.source}"/>
71 <foreach item="String" in="${docformats}" delim="," property="docformat">
72 <call target="copyimages"/>
73 <call target="${docformat}"/>
74 </foreach>
75 </if>
76 </foreach>
77 </target>
79 <!-- ====================================================================== -->
80 <!-- ====================================================================== -->
82 <target name="clean" description="remove all generated files">
83 <if test="${cleanup == 'yes'}">
84 <delete dir="output" failonerror="false"/>
85 </if>
86 </target>
88 <!-- ====================================================================== -->
89 <!-- ====================================================================== -->
91 <target name="prepare" description="Create directories" depends="clean">
92 <mkdir dir="output"/>
93 <call target="prepare.custom" if="${target::exists('prepare.custom')}"/>
95 <property name="fontpath" value="/usr/share/fonts/truetype/" if="${platform::is-unix() and not property::exists('fontpath')}"/>
96 <property name="fontpath" value="${string::replace(environment::get-variable('windir'), '\', '/')}/Fonts/" if="${platform::is-windows() and not property::exists('fontpath')}"/>
97 <fail unless="${directory::exists(fontpath)}">fontpath '${fontpath}' does not exist</fail>
99 <!-- ensure "Version" translation invariant -->
100 <copy file="source/${lang.base}/Version.in" tofile="source/${lang.base}/version.xml" overwrite="true"/>
102 <!-- tune path to xsltproc.exe in aspell.bat -->
103 <copy file="Aspell/aspell.bat.in" tofile="Aspell/aspell.bat" overwrite="true" unless="${platform::is-unix()}">
104 <filterchain>
105 <replacetokens begintoken="$" endtoken="$">
106 <token key="XSLTProcPath" value="${path.bin}" />
107 </replacetokens>
108 </filterchain>
109 </copy>
111 </target>
113 <!-- ====================================================================== -->
114 <!-- ====================================================================== -->
116 <target name="copyimages" description="Copy images">
117 <delete dir="${doc.target.work}/images" failonerror="false"/>
118 <mkdir dir="${doc.target.work}/images"/>
119 <mkdir dir="${doc.target.work}/images/callouts" if="${app=='TortoiseGit' and external.gitdocs=='0'}"/>
121 <property name="xslt.params" value="${xsl.pdf.params}"/>
122 <property name="xslt.target" value="${path::get-temp-file-name()}"/>
123 <exec program="xsltproc"
124 commandline="${xslt.params} --output ${xslt.target} images/extract-images.xsl ${xslt.source}"
125 basedir="${path.bin}"
126 verbose="false"/>
127 <foreach item="Line" in="${xslt.target}" property="filename" trim="Both">
128 <property name="destname" value="${doc.target.work}/images/${filename}"/>
129 <copy file="images/${lang.target}/${filename}" tofile="${destname}" if="${file::exists(path::combine('images', path::combine(lang.target, filename)))}"/>
130 <copy file="images/${lang.base}/${filename}" tofile="${destname}" unless="${file::exists(destname)}"/>
131 </foreach>
133 <copy todir="${doc.target.work}/images">
134 <fileset basedir="images/${lang.base}">
135 <include name="caution.png"/>
136 <include name="warning.png"/>
137 <include name="important.png"/>
138 <include name="tip.png"/>
139 <include name="note.png"/>
140 <include name="link.png"/>
141 </fileset>
142 </copy>
144 <copy todir="${doc.target.work}/images/callouts" if="${app=='TortoiseGit' and external.gitdocs=='0'}">
145 <fileset basedir="images/${lang.base}/callouts">
146 <include name="*.png" unless="${docformat=='pdf'}"/>
147 <include name="*.svg" if="${docformat=='pdf'}"/>
148 </fileset>
149 </copy>
150 </target>
152 <!-- ====================================================================== -->
153 <!-- ====================================================================== -->
155 <target name="uptodate" description="Check whether the given target is up to date">
157 <echo message="Checking if '${file.target}' is up to date"/>
158 <uptodate property="file.target.uptodate">
159 <sourcefiles>
160 <include name="source/${lang.target}/${app}/**/*.xml"/>
161 <include name="source/${lang.target}/glossary.xml"/>
162 <include name="source/${lang.target}/wishlist.xml"/>
163 <include name="source/${lang.target}/version.in"/>
164 </sourcefiles>
165 <targetfiles>
166 <include name="${file.target}"/>
167 </targetfiles>
168 </uptodate>
169 <if test="${file.target.uptodate}">
170 <echo message="Up to date"/>
171 </if>
172 </target>
174 <!-- ====================================================================== -->
175 <!-- Run xsltproc with the defined parameters -->
176 <!-- ====================================================================== -->
178 <target name="xsltproc" description="Run xsltproc with the defined parameters">
179 <echo message="Processing XML Source" />
181 <!-- Check whether a language specific xsl file exists and use it -->
182 <!-- if none is found, load XSL file from default location. -->
183 <property name="xslt.file.lang" value="${path.user.xsl}/${lang.target}/${xslt.file}" />
184 <property name="xslt.file" value="${xslt.file.lang}" if="${file::exists(xslt.file.lang)}"/>
185 <property name="xslt.file" value="${path.user.xsl}/${xslt.file}" unless="${file::exists(xslt.file.lang)}"/>
187 <echo message="Stylesheet: ${xslt.file}" />
188 <echo message="Parameters: ${xslt.params}" />
189 <property name="xslt.output.file" value="${path::get-temp-file-name()}"/>
190 <exec program="xsltproc"
191 commandline="${xslt.params} --output ${xslt.target} ${xslt.file} ${xslt.source}"
192 basedir="${path.bin}"
193 output="${xslt.output.file}"
194 verbose="false"/>
195 <loadfile file="${xslt.output.file}" property="xsltproc.output" />
196 <fail if="${string::contains(xsltproc.output, ': parser error :')}">"Parser error" found</fail>
197 <fail if="${string::contains(xsltproc.output, 'Error: no ID for constraint linkend:')}">"Error: no ID for constraint linkend:" found</fail>
198 <fail if="${string::contains(xsltproc.output, 'ERROR: xref linking to ')}">"ERROR: xref linking to" found</fail>
199 <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>
200 </target>
202 <!-- ====================================================================== -->
203 <!-- Profile source into a single file -->
204 <!-- ====================================================================== -->
206 <target name="profile" description="Profile source into a single file" >
208 <call target="uptodate"/>
210 <if test="${not file.target.uptodate}">
211 <property name="xslt.params" value="${xsl.profile.params}"/>
212 <property name="xslt.file" value="${xsl.profile.file}"/>
213 <property name="xslt.target" value="${file.target}.tmp"/>
215 <echo message="Profiling into: ${file.target}"/>
216 <call target="xsltproc"/>
218 <!-- Removes the moreinfo="" attributes added by xsltproc -->
219 <move file="${xslt.target}" tofile="${file.target}" overwrite="true">
220 <filterchain>
221 <replacestring from=" moreinfo=&quot;none&quot;" to="" />
222 </filterchain>
223 </move>
224 </if>
225 </target>
227 <!-- ====================================================================== -->
228 <!-- Create po template for each application from sources -->
229 <!-- ====================================================================== -->
231 <target name="potfile" description="Create po template from sources">
232 <property name="lang.target" value="${lang.base}"/>
234 <!-- ensure "Version" translation invariant -->
235 <copy file="source\${lang.base}\version.in" tofile="source\${lang.base}\version.xml" overwrite="true"/>
237 <foreach item="String" in="${potemplates}" delim="," property="app">
239 <property name="potfile" value="po/${app}.pot" />
240 <property name="xslt.source" value="source/${lang.base}/${app}/${app}.xml"/>
241 <property name="file.target" value="source/${app}_${lang.base}.xml"/>
243 <echo message="------------------------------------------------------------"/>
244 <echo message="Checking if ${potfile} is up to date"/>
246 <call target="profile" />
248 <if test="${not file::up-to-date(file.target, potfile)}">
249 <echo message="Creating po template from sources"/>
250 <exec program="python"
251 commandline="xml2po.py -e -o ${potfile}.tmp ${file.target}"
252 verbose="false"/>
254 <!-- Adjust path to source file -->
255 <move file="${potfile}.tmp" tofile="${potfile}" overwrite="true">
256 <filterchain>
257 <replacestring from="#: ${file.target}" to="#: ../${file.target}" />
258 </filterchain>
259 </move>
260 </if>
262 <echo message="" />
263 </foreach>
264 </target>
266 <!-- ====================================================================== -->
267 <!-- Create translated source files -->
268 <!-- ====================================================================== -->
270 <target name="translate" description="Create translated source file">
271 <property name="lang.pofile" value="po/${app}_${lang.target}.po"/>
273 <echo message="Translating: '${app} ${lang.target}' This may take a few minutes"/>
275 <exec program="msgfmt"
276 commandline="${lang.pofile} -o ${lang.target}.mo"
277 basedir="${path.gettext}"
278 verbose="false"/>
280 <foreach item="File" property="file.base">
281 <in>
282 <items>
283 <include name="source/${lang.base}/${app}/**/*.xml"/>
284 <include name="source/${lang.base}/glossary.xml"/>
285 <include name="source/${lang.base}/wishlist.xml"/>
286 <include name="source/${lang.base}/version.in"/>
287 </items>
288 </in>
289 <do>
290 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
292 <uptodate property="file.target.uptodate">
293 <sourcefiles>
294 <include name="${file.base}"/>
295 <include name="${lang.pofile}"/>
296 </sourcefiles>
297 <targetfiles>
298 <include name="${file.target}"/>
299 </targetfiles>
300 </uptodate>
302 <if test="${not file.target.uptodate}">
304 <echo message="Translating: ${path::get-file-name(file.target)}"/>
305 <property name="dir.target" value="${path::get-directory-name(file.target)}"/>
306 <mkdir dir="${dir.target}" unless="${directory::exists(dir.target)}"/>
307 <exec program="python"
308 commandline='xml2po.py -t "${lang.target}.mo" -o "${file.target}" "${file.base}"'
309 verbose="false"/>
310 </if>
312 </do>
313 </foreach>
315 <!--
316 <foreach item="File" property="file.base">
317 <in>
318 <items refid="files.exclude" />
319 </in>
320 <do>
321 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
322 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
323 </do>
324 </foreach>
327 <delete file="${lang.target}.mo"/>
328 </target>
330 <!-- ====================================================================== -->
331 <!-- Try to update version info in the version file -->
332 <!-- ====================================================================== -->
334 <target name="UpdateVersionInfo" description="Updates the version file with version info">
336 <copy
337 file="source/${lang.target}/Version.in"
338 tofile="source/${lang.target}/version.xml"
339 overwrite="true">
341 <filterchain>
342 <replacetokens begintoken="$" endtoken="$">
343 <token key="MajorVersion" value="${environment::get-variable('MajorVersion')}"/>
344 <token key="MinorVersion" value="${environment::get-variable('MinorVersion')}"/>
345 <token key="MicroVersion" value="${environment::get-variable('MicroVersion')}"/>
346 </replacetokens>
347 </filterchain>
348 </copy>
350 </target>
352 <!-- ====================================================================== -->
353 <!-- Run spellchecker on files -->
354 <!-- ====================================================================== -->
356 <target name="spellcheck" description="Run spellchecker on files">
357 <echo message="Spellchecking: '${app} ${lang.target}' This may take a few minutes"/>
358 <property name="spellcheck.log" value="Aspell/${app}_${lang.target}.log"/>
359 <property name="script.extension" value=".bat" if="${platform::is-windows()}"/>
360 <property name="script.extension" value=".sh" if="${platform::is-unix()}"/>
361 <mkdir dir="Aspell/${app}_${lang.target}"/>
363 <delete dir="${spellcheck.log}" failonerror="false"/>
365 <copy file="Aspell/TortoiseGit.tmpl.pws" tofile="Aspell/Temp.pws" overwrite="true" inputencoding="utf-8" outputencoding="utf-8">
366 <filterchain>
367 <replacetokens begintoken="$" endtoken="$">
368 <token key="LANG" value="${lang.target}" />
369 </replacetokens>
370 </filterchain>
371 </copy>
372 <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 -->
374 <foreach item="File" property="file.base">
375 <in>
376 <items>
377 <exclude name="source/${lang.base}/TortoiseGit/git_doc/*.xml"/>
378 <include name="source/${lang.base}/${app}/**/*.xml"/>
379 <include name="source/${lang.base}/glossary.xml"/>
380 <include name="source/${lang.base}/wishlist.xml"/>
381 </items>
382 </in>
383 <do>
384 <property name="file.target" value="${string::replace(file.base, '/' + lang.base + '/', '/' + lang.target + '/')}"/>
385 <property name="file.log" value="Aspell/${app}_${lang.target}/${path::get-file-name(file.target)}.log"/>
387 <uptodate property="file.target.uptodate">
388 <sourcefiles>
389 <include name="${file.target}"/>
390 <include name="Aspell/${lang.target}.pws"/>
391 <include name="Aspell/TortoiseGit.tmpl.pws"/>
392 </sourcefiles>
393 <targetfiles>
394 <include name="${file.log}"/>
395 </targetfiles>
396 </uptodate>
398 <if test="${not file.target.uptodate}">
399 <echo message="Checking: ${path::get-file-name(file.target)}"/>
400 <exec program="Aspell/aspell${script.extension}"
401 commandline="&quot;${path.spellcheck}&quot; &quot;${lang.target}&quot; &quot;${file.target}&quot; &quot;${file.log}&quot;"
402 failonerror="false"/>
403 </if>
404 <exec program="Aspell/append${script.extension}"
405 commandline="${file.log} ${spellcheck.log}"/>
406 </do>
407 </foreach>
408 </target>
410 <!-- ====================================================================== -->
411 <!-- Create PDF documentation -->
412 <!-- ====================================================================== -->
414 <target name="pdf" description="Create PDF documentation">
416 <property name="file.target" value="output/${app}-${docverstring}-${lang.target}.pdf"/>
417 <call target="uptodate"/>
419 <if test="${not file.target.uptodate}">
420 <property name="xslt.params" value="${xsl.pdf.params}"/>
421 <property name="xslt.file" value="${xsl.pdf.file}"/>
422 <property name="xslt.final" value="${doc.target.work}/${doc.target.name}"/>
423 <!-- set xslt.target to the name of the temp file -->
424 <property name="xslt.target" value="${xslt.final}.tmp"/>
426 <call target="xsltproc" />
428 <!-- Removes the span="inherit" attribute added by xsltproc, which causes a warning -->
429 <move file="${xslt.target}" tofile="${xslt.final}.fo" overwrite="true" inputencoding="utf-8" outputencoding="utf-8">
430 <filterchain>
431 <replacestring from="span=&quot;inherit&quot; " to="" />
432 <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;" />
433 </filterchain>
434 </move>
436 <property name="userconfig.langtemplate" value="${path.user.xsl}/${lang.target}/userconfig.template.xml" />
437 <property name="userconfig.lang" value="${path.user.xsl}/${lang.target}/userconfig.xml" />
439 <if test="${file::exists(userconfig.langtemplate)}">
440 <loadfile file="${userconfig.langtemplate}" property="configfile">
441 <filterchain>
442 <replacetokens begintoken="%" endtoken="%">
443 <token key="FONTSDIR" value="${fontpath}" />
444 </replacetokens>
445 </filterchain>
446 </loadfile>
447 <echo file="${userconfig.lang}" message="${configfile}" />
448 </if>
449 <property name="commandline" value="-q -fo ${xslt.final}.fo -pdf ${file.target}"/>
450 <property name="commandline" value="-c ${userconfig.lang} ${commandline}" if="${file::exists(userconfig.lang)}"/>
452 <exec program="${name.fop}"
453 commandline="${commandline}"
454 basedir="${path.fop}"
455 verbose="false"/>
456 </if>
457 </target>
459 <!-- ====================================================================== -->
460 <!-- Create CHM documentation -->
461 <!-- ====================================================================== -->
463 <target name="chm" description="Create CHM documentation">
465 <property name="file.target" value="${doc.target.work}.chm"/>
466 <call target="uptodate"/>
468 <if test="${not file.target.uptodate}">
469 <property name="xslt.params" value="${xsl.chm.params}"/>
470 <property name="xslt.file" value="${xsl.chm.file}"/>
471 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
473 <call target="xsltproc" />
475 <!-- The CHM helpcontext target resides in an external build file -->
476 <call target="help.prepare" if="${target::exists('help.prepare')}"/>
478 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
480 <exec program="SBAppLocale.exe"
481 commandline="${lang.target.code} ${path.bin}/hhc.exe ${doc.target.work}/htmlhelp.hhp"
482 basedir="${path.bin}"
483 resultproperty="result.hhc"
484 failonerror="false"
485 verbose="false"
486 timeout="600000" />
488 <copy file="${doc.target.work}/htmlhelp.chm" tofile="${file.target}"/>
489 </if>
490 <!--
491 <delete>
492 <fileset>
493 <include name="${doc.target.work}/*.*"/>
494 </fileset>
495 </delete>
497 </target>
499 <!-- ====================================================================== -->
500 <!-- Create HTML multi page documentation -->
501 <!-- ====================================================================== -->
502 <target name="html" description="Create HTML documentation" depends="">
504 <property name="file.target" value="${doc.target.work}/index.html"/>
505 <call target="uptodate"/>
507 <if test="${not file.target.uptodate}">
508 <property name="xslt.params" value="${xsl.htmlsingle.params}"/>
509 <property name="xslt.file" value="${xsl.htmlsingle.file}"/>
510 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
512 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
513 <copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
515 <call target="xsltproc" />
517 </if>
518 </target>
520 <!-- ====================================================================== -->
521 <!-- Create HTML single page documentation -->
522 <!-- ====================================================================== -->
524 <target name="htmlsingle" description="Create HTML single page documentation" depends="">
526 <property name="file.target" value="${doc.target.work}/help-onepage.html"/>
527 <call target="uptodate"/>
529 <if test="${not file.target.uptodate}">
530 <property name="xslt.params" value="${xsl.html.params}"/>
531 <property name="xslt.file" value="${xsl.html.file}"/>
532 <property name="xslt.target" value="${file.target}"/>
534 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
535 <copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
537 <call target="xsltproc" />
539 </if>
540 </target>
542 </project>