3 ============================================================
4 $Date: 2008-12-14 09:06:16 +0800 (Sun, 14 Dec 2008) $
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.
16 <project name=
"Documentation" default=
"all" basedir=
".">
18 Builds the Documentation in all languages and all output formats
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 <!-- ====================================================================== -->
31 description=
"Loop over all languages, output formats and applications and build documentation"
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}" />
41 <call target=
"doit" failonerror=
"${critical or lang.base==lang.target}"/>
45 <!-- ====================================================================== -->
46 <!-- Loop over all applications and output formats -->
47 <!-- ====================================================================== -->
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}" />
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}"/>
82 <!-- ====================================================================== -->
83 <!-- ====================================================================== -->
85 <target name=
"clean" description=
"remove all generated files">
86 <if test=
"${cleanup == 'yes'}">
87 <delete dir=
"output" failonerror=
"false"/>
91 <!-- ====================================================================== -->
92 <!-- ====================================================================== -->
94 <target name=
"prepare" description=
"Create directories" depends=
"clean">
96 <call target=
"prepare.custom" if=
"${target::exists('prepare.custom')}"/>
98 <!-- find the path to the fonts -->
99 <script language=
"C#">
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 );
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">
119 <replacetokens begintoken=
"$" endtoken=
"$">
120 <token key=
"XSLTProcPath" value=
"${path.bin}" />
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}">
139 <copy todir=
"${doc.target.work}/images" unless=
"${lang.base==lang.target}" overwrite=
"true">
140 <fileset basedir=
"images/${lang.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">
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"/>
161 <include name=
"${file.target}"/>
164 <if test=
"${file.target.uptodate}">
165 <echo message=
"Up to date"/>
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}"
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">
209 <replacestring from=
" moreinfo="none"" to=
"" />
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}"
242 <!-- Adjust path to source file -->
243 <move file=
"${potfile}.tmp" tofile=
"${potfile}" overwrite=
"true">
245 <replacestring from=
"#: ${file.target}" to=
"#: ../${file.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}"
268 <foreach item=
"File" property=
"file.base">
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"/>
279 <property name=
"file.target" value=
"${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
281 <uptodate property=
"file.target.uptodate">
283 <include name=
"${file.base}"/>
284 <include name=
"${lang.pofile}"/>
287 <include name=
"${file.target}"/>
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}"'
305 <foreach item="File" property="file.base">
307 <items refid="files.exclude" />
310 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
311 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
316 <delete file=
"${lang.target}.mo"/>
319 <!-- ====================================================================== -->
320 <!-- Try to update version info in the version file -->
321 <!-- ====================================================================== -->
323 <target name=
"UpdateVersionInfo" description=
"Updates the version file with version info">
326 file=
"source\${lang.target}\version.in"
327 tofile=
"source\${lang.target}\version.xml"
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')}"/>
336 <token key="WCREV" value="${environment::get-variable('WCREV')}"/>
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">
359 <replacetokens begintoken=
"$" endtoken=
"$">
360 <token key=
"LANG" value=
"${lang.target}" />
365 <foreach item=
"File" property=
"file.base">
368 <include name=
"source/${lang.base}/${app}/**/*.xml"/>
369 <include name=
"source/${lang.base}/glossary.xml"/>
370 <include name=
"source/${lang.base}/wishlist.xml"/>
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">
379 <include name=
"${file.target}"/>
380 <include name=
"ASpell/${lang.target}.pws"/>
381 <include name=
"ASpell/TortoiseGit.tmpl.pws"/>
384 <include name=
"${file.log}"/>
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"/>
394 <exec program=
"Aspell/append.bat"
395 commandline=
"${file.log} ${spellcheck.log}"/>
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">
422 <replacetokens begintoken=
"%" endtoken=
"%">
423 <token key=
"FONTSDIR" value=
"${fontpath}" />
427 <echo file=
"${userconfig.lang}" message=
"${configfile}" />
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}"
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"
468 <copy file=
"${doc.target.work}/htmlhelp.chm" tofile=
"${file.target}"/>
473 <include name="${doc.target.work}/*.*"/>
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" />
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" />
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" />
536 <move file=
"output\doxygen\html\GitAPI.chm" tofile=
"output\GitAPI.chm" overwrite=
"true" />
537 <delete dir=
"output\doxygen" />
538 <delete file=
"Doxyfile" />
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" />
549 <move file=
"output\doxygen\html\TortoiseAPI.chm" tofile=
"output\TortoiseGitAPI.chm" overwrite=
"true" />
550 <delete dir=
"output\doxygen" />
551 <delete file=
"Doxyfile" />