To make ref label easier to read, draw white text if back color is considered dark
[TortoiseGit.git] / doc / doc.build
blob12b6dc27374706dfc2fd60958b9f945281afede5
1 <?xml version="1.0"?>
2 <!--
3 ============================================================
4 $Date: 2008-12-14 09:06:16 +0800 (Sun, 14 Dec 2008) $
5 $Author: simonlarge $
6 $Rev: 14835 $
7 ============================================================
9 NAnt build script for the TortoiseGit documentation
11 All project specific configuration is stored in doc.build.include.
12 All user/site specific configuration is stored in doc.build.user.
14 -->
16 <project name="Documentation" default="all" basedir=".">
17 <description>
18 Builds the Documentation in all languages and all output formats
19 </description>
21 <!-- default: we don't clean first -->
22 <property name="cleanup" value="" overwrite="false" />
24 <include buildfile="doc.build.include"/>
26 <!-- ====================================================================== -->
27 <!-- Loop over all languages -->
28 <!-- ====================================================================== -->
30 <target name="all"
31 description="Loop over all languages, output formats and applications and build documentation"
32 depends="prepare" >
34 <foreach item="String" in="${languages}" delim="," property="lang.target">
35 <!-- language code for English (US) (default)-->
36 <property name="lang.target.code" value="1033" />
37 <property name="languagebuildfile" value="${path.user.xsl}/${lang.target}/lang.build" />
38 <if test="${file::exists(languagebuildfile)}" >
39 <include buildfile="${languagebuildfile}" />
40 </if>
41 <call target="doit" failonerror="${critical or lang.base==lang.target}"/>
42 </foreach>
43 </target>
45 <!-- ====================================================================== -->
46 <!-- Loop over all applications and output formats -->
47 <!-- ====================================================================== -->
49 <target name="doit">
51 <foreach item="String" in="${applications}" delim="," property="app">
52 <property name="doc.source.file" value="source/${lang.base}/${app}.xml"/>
53 <property name="doc.base.name" value="${app}_${lang.base}"/>
54 <property name="doc.base.work" value="output/${doc.base.name}"/>
56 <property name="doc.target.name" value="${app}_${lang.target}"/>
57 <property name="doc.target.work" value="output/${doc.target.name}"/>
58 <property name="doc.target.source" value="source/${lang.target}/${app}/${app}.xml"/>
59 <property name="pofiletotranslate" value="po/${app}_${lang.target}.po" />
61 <echo message="------------------------------------------------------------"/>
62 <echo message="Creating '${doc.target.name}' documentation"/>
64 <if test="${file::exists(pofiletotranslate)}" >
65 <call target="translate" unless="${lang.base==lang.target}" />
66 </if>
67 <if test="${lang.base==lang.target or file::exists(pofiletotranslate)}" >
68 <!-- update version info in version.xml -->
69 <call target="UpdateVersionInfo"/>
71 <call target="spellcheck" if="${property::exists('spellcheck') and spellcheck=='true'}"/>
72 <call target="copyimages"/>
74 <property name="xslt.source" value="${doc.target.source}"/>
75 <foreach item="String" in="${docformats}" delim="," property="docformat">
76 <call target="${docformat}"/>
77 </foreach>
78 </if>
79 </foreach>
80 </target>
82 <!-- ====================================================================== -->
83 <!-- ====================================================================== -->
85 <target name="clean" description="remove all generated files">
86 <if test="${cleanup == 'yes'}">
87 <delete dir="output" failonerror="false"/>
88 </if>
89 </target>
91 <!-- ====================================================================== -->
92 <!-- ====================================================================== -->
94 <target name="prepare" description="Create directories" depends="clean">
95 <mkdir dir="output"/>
96 <call target="prepare.custom" if="${target::exists('prepare.custom')}"/>
98 <!-- find the path to the fonts -->
99 <script language="C#">
100 <code>
101 <![CDATA[
102 public static void ScriptMain(Project project)
104 string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
105 string fontsPath = Path.GetDirectoryName(systemPath) + Path.DirectorySeparatorChar + "FONTS";
106 fontsPath = fontsPath.Replace('\\','/');
107 project.Properties.Add("fontpath", fontsPath );
110 </code>
111 </script>
113 <!-- ensure "Version" translation invariant -->
114 <copy file="source\${lang.base}\version.in" tofile="source\${lang.base}\version.xml" overwrite="true"/>
116 <!-- tune path to xsltproc.exe in aspell.bat -->
117 <copy file="Aspell/aspell.in" tofile="Aspell/aspell.bat" overwrite="true">
118 <filterchain>
119 <replacetokens begintoken="$" endtoken="$">
120 <token key="XSLTProcPath" value="${path.bin}" />
121 </replacetokens>
122 </filterchain>
123 </copy>
125 </target>
127 <!-- ====================================================================== -->
128 <!-- ====================================================================== -->
130 <target name="copyimages" description="Copy images">
131 <delete dir="${doc.target.work}/images" failonerror="false"/>
132 <mkdir dir="${doc.target.work}/images"/>
133 <copy todir="${doc.target.work}/images">
134 <fileset basedir="images/${lang.base}">
135 <include name="*"/>
136 </fileset>
137 </copy>
139 <copy todir="${doc.target.work}/images" unless="${lang.base==lang.target}" overwrite="true">
140 <fileset basedir="images/${lang.target}">
141 <include name="*"/>
142 </fileset>
143 </copy>
144 </target>
146 <!-- ====================================================================== -->
147 <!-- ====================================================================== -->
149 <target name="uptodate" description="Check whether the given target is up to date">
151 <echo message="Checking if '${file.target}' is up to date"/>
152 <uptodate property="file.target.uptodate">
153 <sourcefiles>
154 <include name="source/${lang.target}/${app}/**/*.xml"/>
155 <include name="source/${lang.target}/pubdate.xml"/>
156 <include name="source/${lang.target}/glossary.xml"/>
157 <include name="source/${lang.target}/wishlist.xml"/>
158 <include name="source/${lang.target}/version.in"/>
159 </sourcefiles>
160 <targetfiles>
161 <include name="${file.target}"/>
162 </targetfiles>
163 </uptodate>
164 <if test="${file.target.uptodate}">
165 <echo message="Up to date"/>
166 </if>
167 </target>
169 <!-- ====================================================================== -->
170 <!-- Run xsltproc with the defined parameters -->
171 <!-- ====================================================================== -->
173 <target name="xsltproc" description="Run xsltproc with the defined parameters">
174 <echo message="Processing XML Source" />
176 <!-- Check whether a language specific xsl file exists and use it -->
177 <!-- if none is found, load XSL file from default location. -->
178 <property name="xslt.file.lang" value="${path.user.xsl}/${lang.target}/${xslt.file}" />
179 <property name="xslt.file" value="${xslt.file.lang}" if="${file::exists(xslt.file.lang)}"/>
180 <property name="xslt.file" value="${path.user.xsl}/${xslt.file}" unless="${file::exists(xslt.file.lang)}"/>
182 <echo message="Stylesheet: ${xslt.file}" />
183 <echo message="Parameters: ${xslt.params}" />
184 <exec program="xsltproc"
185 commandline="${xslt.params} --output ${xslt.target} ${xslt.file} ${xslt.source}"
186 basedir="${path.bin}"
187 verbose="false"/>
188 </target>
190 <!-- ====================================================================== -->
191 <!-- Profile source into a single file -->
192 <!-- ====================================================================== -->
194 <target name="profile" description="Profile source into a single file" >
196 <call target="uptodate"/>
198 <if test="${not file.target.uptodate}">
199 <property name="xslt.params" value="${xsl.profile.params}"/>
200 <property name="xslt.file" value="${xsl.profile.file}"/>
201 <property name="xslt.target" value="${file.target}.tmp"/>
203 <echo message="Profiling into: ${file.target}"/>
204 <call target="xsltproc"/>
206 <!-- Removes the moreinfo="" attributes added by xsltproc -->
207 <move file="${xslt.target}" tofile="${file.target}" overwrite="true">
208 <filterchain>
209 <replacestring from=" moreinfo=&quot;none&quot;" to="" />
210 </filterchain>
211 </move>
212 </if>
213 </target>
215 <!-- ====================================================================== -->
216 <!-- Create po template for each application from sources -->
217 <!-- ====================================================================== -->
219 <target name="potfile" description="Create po template from sources">
220 <property name="lang.target" value="${lang.base}"/>
222 <!-- ensure "Version" translation invariant -->
223 <copy file="source\${lang.base}\version.in" tofile="source\${lang.base}\version.xml" overwrite="true"/>
225 <foreach item="String" in="${potemplates}" delim="," property="app">
227 <property name="potfile" value="po/${app}.pot" />
228 <property name="xslt.source" value="source/${lang.base}/${app}/${app}.xml"/>
229 <property name="file.target" value="source/${app}_${lang.base}.xml"/>
231 <echo message="------------------------------------------------------------"/>
232 <echo message="Checking if ${potfile} is up to date"/>
234 <call target="profile" />
236 <if test="${not file::up-to-date(file.target, potfile)}">
237 <echo message="Creating po template from sources"/>
238 <exec program="python"
239 commandline="xml2po.py -e -o ${potfile}.tmp ${file.target}"
240 verbose="false"/>
242 <!-- Adjust path to source file -->
243 <move file="${potfile}.tmp" tofile="${potfile}" overwrite="true">
244 <filterchain>
245 <replacestring from="#: ${file.target}" to="#: ../${file.target}" />
246 </filterchain>
247 </move>
248 </if>
250 <echo message="" />
251 </foreach>
252 </target>
254 <!-- ====================================================================== -->
255 <!-- Create translated source files -->
256 <!-- ====================================================================== -->
258 <target name="translate" description="Create translated source file">
259 <property name="lang.pofile" value="po/${app}_${lang.target}.po"/>
261 <echo message="Translating: '${app} ${lang.target}' This may take a few minutes"/>
263 <exec program="msgfmt"
264 commandline="${lang.pofile} -o ${lang.target}.mo"
265 basedir="${path.gettext}"
266 verbose="false"/>
268 <foreach item="File" property="file.base">
269 <in>
270 <items>
271 <include name="source/${lang.base}/${app}/**/*.xml"/>
272 <include name="source/${lang.base}/pubdate.xml"/>
273 <include name="source/${lang.base}/glossary.xml"/>
274 <include name="source/${lang.base}/wishlist.xml"/>
275 <include name="source/${lang.base}/version.in"/>
276 </items>
277 </in>
278 <do>
279 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
281 <uptodate property="file.target.uptodate">
282 <sourcefiles>
283 <include name="${file.base}"/>
284 <include name="${lang.pofile}"/>
285 </sourcefiles>
286 <targetfiles>
287 <include name="${file.target}"/>
288 </targetfiles>
289 </uptodate>
291 <if test="${not file.target.uptodate}">
293 <echo message="Translating: ${path::get-file-name(file.target)}"/>
294 <property name="dir.target" value="${path::get-directory-name(file.target)}"/>
295 <mkdir dir="${dir.target}" unless="${directory::exists(dir.target)}"/>
296 <exec program="python"
297 commandline='xml2po.py -t "${lang.target}.mo" -o "${file.target}" "${file.base}"'
298 verbose="false"/>
299 </if>
301 </do>
302 </foreach>
304 <!--
305 <foreach item="File" property="file.base">
306 <in>
307 <items refid="files.exclude" />
308 </in>
309 <do>
310 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
311 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
312 </do>
313 </foreach>
316 <delete file="${lang.target}.mo"/>
317 </target>
319 <!-- ====================================================================== -->
320 <!-- Try to update version info in the version file -->
321 <!-- ====================================================================== -->
323 <target name="UpdateVersionInfo" description="Updates the version file with version info">
325 <copy
326 file="source\${lang.target}\version.in"
327 tofile="source\${lang.target}\version.xml"
328 overwrite="true">
330 <filterchain>
331 <replacetokens begintoken="$" endtoken="$">
332 <token key="MajorVersion" value="${environment::get-variable('MajorVersion')}"/>
333 <token key="MinorVersion" value="${environment::get-variable('MinorVersion')}"/>
334 <token key="MicroVersion" value="${environment::get-variable('Microversion')}"/>
335 <!--
336 <token key="WCREV" value="${environment::get-variable('WCREV')}"/>
338 </replacetokens>
339 </filterchain>
340 </copy>
342 </target>
344 <!-- ====================================================================== -->
345 <!-- Run spellchecker on files -->
346 <!-- ====================================================================== -->
348 <target name="spellcheck" description="Run spellchecker on files">
349 <echo message="Spellchecking: '${app} ${lang.target}' This may take a few minutes"/>
350 <property name="spellcheck.log" value="ASpell/${app}_${lang.target}.log"/>
351 <mkdir dir="ASpell/${app}_${lang.target}"/>
353 <echo message="--- Spellchecking: '${lang.target}'"
354 file="${spellcheck.log}"
355 failonerror="false"/>
357 <copy file="Aspell/TortoiseGit.tmpl.pws" tofile="Aspell/Temp.pws" overwrite="true">
358 <filterchain>
359 <replacetokens begintoken="$" endtoken="$">
360 <token key="LANG" value="${lang.target}" />
361 </replacetokens>
362 </filterchain>
363 </copy>
365 <foreach item="File" property="file.base">
366 <in>
367 <items>
368 <include name="source/${lang.base}/${app}/**/*.xml"/>
369 <include name="source/${lang.base}/glossary.xml"/>
370 <include name="source/${lang.base}/wishlist.xml"/>
371 </items>
372 </in>
373 <do>
374 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
375 <property name="file.log" value="ASpell\${app}_${lang.target}\${path::get-file-name(file.target)}.log"/>
377 <uptodate property="file.target.uptodate">
378 <sourcefiles>
379 <include name="${file.target}"/>
380 <include name="ASpell/${lang.target}.pws"/>
381 <include name="ASpell/TortoiseGit.tmpl.pws"/>
382 </sourcefiles>
383 <targetfiles>
384 <include name="${file.log}"/>
385 </targetfiles>
386 </uptodate>
388 <if test="${not file.target.uptodate}">
389 <echo message="Checking: ${path::get-file-name(file.target)}"/>
390 <exec program="Aspell/aspell.bat"
391 commandline="${path.spellcheck} ${lang.target} ${file.target} ${file.log}"
392 failonerror="false"/>
393 </if>
394 <exec program="Aspell/append.bat"
395 commandline="${file.log} ${spellcheck.log}"/>
396 </do>
397 </foreach>
398 </target>
400 <!-- ====================================================================== -->
401 <!-- Create PDF documentation -->
402 <!-- ====================================================================== -->
404 <target name="pdf" description="Create PDF documentation">
406 <property name="file.target" value="output/${app}-${docverstring}-${lang.target}.pdf"/>
407 <call target="uptodate"/>
409 <if test="${not file.target.uptodate}">
410 <property name="xslt.params" value="${xsl.pdf.params}"/>
411 <property name="xslt.file" value="${xsl.pdf.file}"/>
412 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}.fo"/>
414 <call target="xsltproc" />
416 <property name="userconfig.langtemplate" value="${path.user.xsl}/${lang.target}/userconfig.template.xml" />
417 <property name="userconfig.lang" value="${path.user.xsl}/${lang.target}/userconfig.xml" />
419 <if test="${file::exists(userconfig.langtemplate)}">
420 <loadfile file="${userconfig.langtemplate}" property="configfile">
421 <filterchain>
422 <replacetokens begintoken="%" endtoken="%">
423 <token key="FONTSDIR" value="${fontpath}" />
424 </replacetokens>
425 </filterchain>
426 </loadfile>
427 <echo file="${userconfig.lang}" message="${configfile}" />
428 </if>
429 <property name="commandline" value="-q -fo ${xslt.target} -pdf ${file.target}"/>
430 <property name="commandline" value="-c ${userconfig.lang} ${commandline}" if="${file::exists(userconfig.lang)}"/>
432 <exec program="fop.bat"
433 commandline="${commandline}"
434 basedir="${path.fop}"
435 verbose="false"/>
436 </if>
437 </target>
439 <!-- ====================================================================== -->
440 <!-- Create CHM documentation -->
441 <!-- ====================================================================== -->
443 <target name="chm" description="Create CHM documentation">
445 <property name="file.target" value="${doc.target.work}.chm"/>
446 <call target="uptodate"/>
448 <if test="${not file.target.uptodate}">
449 <property name="xslt.params" value="${xsl.chm.params}"/>
450 <property name="xslt.file" value="${xsl.chm.file}"/>
451 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
453 <call target="xsltproc" />
455 <!-- The CHM helpcontext target resides in an external build file -->
456 <call target="help.prepare" if="${target::exists('help.prepare')}"/>
458 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
460 <exec program="SBAppLocale.exe"
461 commandline="${lang.target.code} ${path.bin}/hhc.exe ${doc.target.work}/htmlhelp.hhp"
462 basedir="${path.bin}"
463 resultproperty="result.hhc"
464 failonerror="false"
465 verbose="false"
466 timeout="600000" />
468 <copy file="${doc.target.work}/htmlhelp.chm" tofile="${file.target}"/>
469 </if>
470 <!--
471 <delete>
472 <fileset>
473 <include name="${doc.target.work}/*.*"/>
474 </fileset>
475 </delete>
477 </target>
479 <!-- ====================================================================== -->
480 <!-- Create HTML multi page documentation -->
481 <!-- ====================================================================== -->
482 <target name="html" description="Create HTML documentation" depends="">
484 <property name="file.target" value="${doc.target.work}/index.html"/>
485 <call target="uptodate"/>
487 <if test="${not file.target.uptodate}">
488 <property name="xslt.params" value="${xsl.htmlsingle.params}"/>
489 <property name="xslt.file" value="${xsl.htmlsingle.file}"/>
490 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
492 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
493 <copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
495 <call target="xsltproc" />
497 </if>
498 </target>
500 <!-- ====================================================================== -->
501 <!-- Create HTML single page documentation -->
502 <!-- ====================================================================== -->
504 <target name="htmlsingle" description="Create HTML single page documentation" depends="">
506 <property name="file.target" value="${doc.target.work}/help-onepage.html"/>
507 <call target="uptodate"/>
509 <if test="${not file.target.uptodate}">
510 <property name="xslt.params" value="${xsl.html.params}"/>
511 <property name="xslt.file" value="${xsl.html.file}"/>
512 <property name="xslt.target" value="${file.target}"/>
514 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
515 <copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
517 <call target="xsltproc" />
519 </if>
520 </target>
522 <!-- ====================================================================== -->
523 <!-- Create the API documentation -->
524 <!-- ====================================================================== -->
526 <target name="apidoc" depends="GitAPIdoc,TortoiseGitAPIdoc" />
528 <target name="GitAPIdoc">
529 <loadfile file="API\DoxyfileSVN" property="GitDoxyFile" />
530 <echo file="Doxyfile" message="${GitDoxyFile}" />
531 <echo file="Doxyfile" message="HHC_LOCATION=${environment::get-variable('HHLOC')}" append="true" />
532 <mkdir dir="output" />
533 <exec program="doxygen.exe">
534 <arg value="Doxyfile" />
535 </exec>
536 <move file="output\doxygen\html\GitAPI.chm" tofile="output\GitAPI.chm" overwrite="true" />
537 <delete dir="output\doxygen" />
538 <delete file="Doxyfile" />
539 </target>
541 <target name="TortoiseGitAPIdoc">
542 <loadfile file="API\Doxyfile" property="TortoiseGitDoxyFile" />
543 <echo file="Doxyfile" message="${TortoiseGitDoxyFile}" />
544 <echo file="Doxyfile" message="HHC_LOCATION=${environment::get-variable('HHLOC')}" append="true" />
545 <mkdir dir="output" />
546 <exec program="doxygen.exe">
547 <arg value="Doxyfile" />
548 </exec>
549 <move file="output\doxygen\html\TortoiseAPI.chm" tofile="output\TortoiseGitAPI.chm" overwrite="true" />
550 <delete dir="output\doxygen" />
551 <delete file="Doxyfile" />
552 </target>
554 </project>