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