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}/glossary.xml"/>
156 <include name=
"source/${lang.target}/wishlist.xml"/>
157 <include name=
"source/${lang.target}/version.in"/>
160 <include name=
"${file.target}"/>
163 <if test=
"${file.target.uptodate}">
164 <echo message=
"Up to date"/>
168 <!-- ====================================================================== -->
169 <!-- Run xsltproc with the defined parameters -->
170 <!-- ====================================================================== -->
172 <target name=
"xsltproc" description=
"Run xsltproc with the defined parameters">
173 <echo message=
"Processing XML Source" />
175 <!-- Check whether a language specific xsl file exists and use it -->
176 <!-- if none is found, load XSL file from default location. -->
177 <property name=
"xslt.file.lang" value=
"${path.user.xsl}/${lang.target}/${xslt.file}" />
178 <property name=
"xslt.file" value=
"${xslt.file.lang}" if=
"${file::exists(xslt.file.lang)}"/>
179 <property name=
"xslt.file" value=
"${path.user.xsl}/${xslt.file}" unless=
"${file::exists(xslt.file.lang)}"/>
181 <echo message=
"Stylesheet: ${xslt.file}" />
182 <echo message=
"Parameters: ${xslt.params}" />
183 <exec program=
"xsltproc"
184 commandline=
"${xslt.params} --output ${xslt.target} ${xslt.file} ${xslt.source}"
185 basedir=
"${path.bin}"
189 <!-- ====================================================================== -->
190 <!-- Profile source into a single file -->
191 <!-- ====================================================================== -->
193 <target name=
"profile" description=
"Profile source into a single file" >
195 <call target=
"uptodate"/>
197 <if test=
"${not file.target.uptodate}">
198 <property name=
"xslt.params" value=
"${xsl.profile.params}"/>
199 <property name=
"xslt.file" value=
"${xsl.profile.file}"/>
200 <property name=
"xslt.target" value=
"${file.target}.tmp"/>
202 <echo message=
"Profiling into: ${file.target}"/>
203 <call target=
"xsltproc"/>
205 <!-- Removes the moreinfo="" attributes added by xsltproc -->
206 <move file=
"${xslt.target}" tofile=
"${file.target}" overwrite=
"true">
208 <replacestring from=
" moreinfo="none"" to=
"" />
214 <!-- ====================================================================== -->
215 <!-- Create po template for each application from sources -->
216 <!-- ====================================================================== -->
218 <target name=
"potfile" description=
"Create po template from sources">
219 <property name=
"lang.target" value=
"${lang.base}"/>
221 <!-- ensure "Version" translation invariant -->
222 <copy file=
"source\${lang.base}\version.in" tofile=
"source\${lang.base}\version.xml" overwrite=
"true"/>
224 <foreach item=
"String" in=
"${potemplates}" delim=
"," property=
"app">
226 <property name=
"potfile" value=
"po/${app}.pot" />
227 <property name=
"xslt.source" value=
"source/${lang.base}/${app}/${app}.xml"/>
228 <property name=
"file.target" value=
"source/${app}_${lang.base}.xml"/>
230 <echo message=
"------------------------------------------------------------"/>
231 <echo message=
"Checking if ${potfile} is up to date"/>
233 <call target=
"profile" />
235 <if test=
"${not file::up-to-date(file.target, potfile)}">
236 <echo message=
"Creating po template from sources"/>
237 <exec program=
"python"
238 commandline=
"xml2po.py -e -o ${potfile}.tmp ${file.target}"
241 <!-- Adjust path to source file -->
242 <move file=
"${potfile}.tmp" tofile=
"${potfile}" overwrite=
"true">
244 <replacestring from=
"#: ${file.target}" to=
"#: ../${file.target}" />
253 <!-- ====================================================================== -->
254 <!-- Create translated source files -->
255 <!-- ====================================================================== -->
257 <target name=
"translate" description=
"Create translated source file">
258 <property name=
"lang.pofile" value=
"po/${app}_${lang.target}.po"/>
260 <echo message=
"Translating: '${app} ${lang.target}' This may take a few minutes"/>
262 <exec program=
"msgfmt"
263 commandline=
"${lang.pofile} -o ${lang.target}.mo"
264 basedir=
"${path.gettext}"
267 <foreach item=
"File" property=
"file.base">
270 <include name=
"source/${lang.base}/${app}/**/*.xml"/>
271 <include name=
"source/${lang.base}/glossary.xml"/>
272 <include name=
"source/${lang.base}/wishlist.xml"/>
273 <include name=
"source/${lang.base}/version.in"/>
277 <property name=
"file.target" value=
"${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
279 <uptodate property=
"file.target.uptodate">
281 <include name=
"${file.base}"/>
282 <include name=
"${lang.pofile}"/>
285 <include name=
"${file.target}"/>
289 <if test=
"${not file.target.uptodate}">
291 <echo message=
"Translating: ${path::get-file-name(file.target)}"/>
292 <property name=
"dir.target" value=
"${path::get-directory-name(file.target)}"/>
293 <mkdir dir=
"${dir.target}" unless=
"${directory::exists(dir.target)}"/>
294 <exec program=
"python"
295 commandline='xml2po.py -t
"${lang.target}.mo" -o
"${file.target}" "${file.base}"'
303 <foreach item="File" property="file.base">
305 <items refid="files.exclude" />
308 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
309 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
314 <delete file=
"${lang.target}.mo"/>
317 <!-- ====================================================================== -->
318 <!-- Try to update version info in the version file -->
319 <!-- ====================================================================== -->
321 <target name=
"UpdateVersionInfo" description=
"Updates the version file with version info">
324 file=
"source\${lang.target}\version.in"
325 tofile=
"source\${lang.target}\version.xml"
329 <replacetokens begintoken=
"$" endtoken=
"$">
330 <token key=
"MajorVersion" value=
"${environment::get-variable('MajorVersion')}"/>
331 <token key=
"MinorVersion" value=
"${environment::get-variable('MinorVersion')}"/>
332 <token key=
"MicroVersion" value=
"${environment::get-variable('Microversion')}"/>
339 <!-- ====================================================================== -->
340 <!-- Run spellchecker on files -->
341 <!-- ====================================================================== -->
343 <target name=
"spellcheck" description=
"Run spellchecker on files">
344 <echo message=
"Spellchecking: '${app} ${lang.target}' This may take a few minutes"/>
345 <property name=
"spellcheck.log" value=
"ASpell/${app}_${lang.target}.log"/>
346 <mkdir dir=
"ASpell/${app}_${lang.target}"/>
348 <echo message=
"--- Spellchecking: '${lang.target}'"
349 file=
"${spellcheck.log}"
350 failonerror=
"false"/>
352 <copy file=
"Aspell/TortoiseGit.tmpl.pws" tofile=
"Aspell/Temp.pws" overwrite=
"true">
354 <replacetokens begintoken=
"$" endtoken=
"$">
355 <token key=
"LANG" value=
"${lang.target}" />
360 <foreach item=
"File" property=
"file.base">
363 <include name=
"source/${lang.base}/${app}/**/*.xml"/>
364 <include name=
"source/${lang.base}/glossary.xml"/>
365 <include name=
"source/${lang.base}/wishlist.xml"/>
369 <property name=
"file.target" value=
"${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
370 <property name=
"file.log" value=
"ASpell\${app}_${lang.target}\${path::get-file-name(file.target)}.log"/>
372 <uptodate property=
"file.target.uptodate">
374 <include name=
"${file.target}"/>
375 <include name=
"ASpell/${lang.target}.pws"/>
376 <include name=
"ASpell/TortoiseGit.tmpl.pws"/>
379 <include name=
"${file.log}"/>
383 <if test=
"${not file.target.uptodate}">
384 <echo message=
"Checking: ${path::get-file-name(file.target)}"/>
385 <exec program=
"Aspell/aspell.bat"
386 commandline=
"${path.spellcheck} ${lang.target} ${file.target} ${file.log}"
387 failonerror=
"false"/>
389 <exec program=
"Aspell/append.bat"
390 commandline=
"${file.log} ${spellcheck.log}"/>
395 <!-- ====================================================================== -->
396 <!-- Create PDF documentation -->
397 <!-- ====================================================================== -->
399 <target name=
"pdf" description=
"Create PDF documentation">
401 <property name=
"file.target" value=
"output/${app}-${docverstring}-${lang.target}.pdf"/>
402 <call target=
"uptodate"/>
404 <if test=
"${not file.target.uptodate}">
405 <property name=
"xslt.params" value=
"${xsl.pdf.params}"/>
406 <property name=
"xslt.file" value=
"${xsl.pdf.file}"/>
407 <property name=
"xslt.final" value=
"${doc.target.work}/${doc.target.name}"/>
408 <!-- set xslt.target to the name of the temp file -->
409 <property name=
"xslt.target" value=
"${xslt.final}.tmp"/>
411 <call target=
"xsltproc" />
413 <!-- Removes the span="inherit" attribute added by xsltproc, which causes a warning -->
414 <move file=
"${xslt.target}" tofile=
"${xslt.final}.fo" overwrite=
"true">
416 <replacestring from=
"span="inherit" " to=
"" />
417 <replacestring from=
"width="auto" height="auto" content-width="auto" content-height="auto"" to=
"inline-progression-dimension.maximum="100%" content-width="scale-down-to-fit" content-height="scale-down-to-fit"" />
421 <property name=
"userconfig.langtemplate" value=
"${path.user.xsl}/${lang.target}/userconfig.template.xml" />
422 <property name=
"userconfig.lang" value=
"${path.user.xsl}/${lang.target}/userconfig.xml" />
424 <if test=
"${file::exists(userconfig.langtemplate)}">
425 <loadfile file=
"${userconfig.langtemplate}" property=
"configfile">
427 <replacetokens begintoken=
"%" endtoken=
"%">
428 <token key=
"FONTSDIR" value=
"${fontpath}" />
432 <echo file=
"${userconfig.lang}" message=
"${configfile}" />
434 <property name=
"commandline" value=
"-q -fo ${xslt.final}.fo -pdf ${file.target}"/>
435 <property name=
"commandline" value=
"-c ${userconfig.lang} ${commandline}" if=
"${file::exists(userconfig.lang)}"/>
437 <exec program=
"fop.bat"
438 commandline=
"${commandline}"
439 basedir=
"${path.fop}"
444 <!-- ====================================================================== -->
445 <!-- Create CHM documentation -->
446 <!-- ====================================================================== -->
448 <target name=
"chm" description=
"Create CHM documentation">
450 <property name=
"file.target" value=
"${doc.target.work}.chm"/>
451 <call target=
"uptodate"/>
453 <if test=
"${not file.target.uptodate}">
454 <property name=
"xslt.params" value=
"${xsl.chm.params}"/>
455 <property name=
"xslt.file" value=
"${xsl.chm.file}"/>
456 <property name=
"xslt.target" value=
"${doc.target.work}/${doc.target.name}"/>
458 <call target=
"xsltproc" />
460 <!-- The CHM helpcontext target resides in an external build file -->
461 <call target=
"help.prepare" if=
"${target::exists('help.prepare')}"/>
463 <copy file=
"${path.user.css}/styles_chm.css" todir=
"${doc.target.work}"/>
465 <exec program=
"SBAppLocale.exe"
466 commandline=
"${lang.target.code} ${path.bin}/hhc.exe ${doc.target.work}/htmlhelp.hhp"
467 basedir=
"${path.bin}"
468 resultproperty=
"result.hhc"
473 <copy file=
"${doc.target.work}/htmlhelp.chm" tofile=
"${file.target}"/>
478 <include name="${doc.target.work}/*.*"/>
484 <!-- ====================================================================== -->
485 <!-- Create HTML multi page documentation -->
486 <!-- ====================================================================== -->
487 <target name=
"html" description=
"Create HTML documentation" depends=
"">
489 <property name=
"file.target" value=
"${doc.target.work}/index.html"/>
490 <call target=
"uptodate"/>
492 <if test=
"${not file.target.uptodate}">
493 <property name=
"xslt.params" value=
"${xsl.htmlsingle.params}"/>
494 <property name=
"xslt.file" value=
"${xsl.htmlsingle.file}"/>
495 <property name=
"xslt.target" value=
"${doc.target.work}/${doc.target.name}"/>
497 <copy file=
"${path.user.css}/styles_chm.css" todir=
"${doc.target.work}"/>
498 <copy file=
"${path.user.css}/styles_html.css" todir=
"${doc.target.work}"/>
500 <call target=
"xsltproc" />
505 <!-- ====================================================================== -->
506 <!-- Create HTML single page documentation -->
507 <!-- ====================================================================== -->
509 <target name=
"htmlsingle" description=
"Create HTML single page documentation" depends=
"">
511 <property name=
"file.target" value=
"${doc.target.work}/help-onepage.html"/>
512 <call target=
"uptodate"/>
514 <if test=
"${not file.target.uptodate}">
515 <property name=
"xslt.params" value=
"${xsl.html.params}"/>
516 <property name=
"xslt.file" value=
"${xsl.html.file}"/>
517 <property name=
"xslt.target" value=
"${file.target}"/>
519 <copy file=
"${path.user.css}/styles_chm.css" todir=
"${doc.target.work}"/>
520 <copy file=
"${path.user.css}/styles_html.css" todir=
"${doc.target.work}"/>
522 <call target=
"xsltproc" />
527 <!-- ====================================================================== -->
528 <!-- Create the API documentation -->
529 <!-- ====================================================================== -->
531 <target name=
"apidoc" depends=
"GitAPIdoc,TortoiseGitAPIdoc" />
533 <target name=
"GitAPIdoc">
534 <loadfile file=
"API\DoxyfileSVN" property=
"GitDoxyFile" />
535 <echo file=
"Doxyfile" message=
"${GitDoxyFile}" />
536 <echo file=
"Doxyfile" message=
"HHC_LOCATION=${environment::get-variable('HHLOC')}" append=
"true" />
537 <mkdir dir=
"output" />
538 <exec program=
"doxygen.exe">
539 <arg value=
"Doxyfile" />
541 <move file=
"output\doxygen\html\GitAPI.chm" tofile=
"output\GitAPI.chm" overwrite=
"true" />
542 <delete dir=
"output\doxygen" />
543 <delete file=
"Doxyfile" />
546 <target name=
"TortoiseGitAPIdoc">
547 <loadfile file=
"API\Doxyfile" property=
"TortoiseGitDoxyFile" />
548 <echo file=
"Doxyfile" message=
"${TortoiseGitDoxyFile}" />
549 <echo file=
"Doxyfile" message=
"HHC_LOCATION=${environment::get-variable('HHLOC')}" append=
"true" />
550 <mkdir dir=
"output" />
551 <exec program=
"doxygen.exe">
552 <arg value=
"Doxyfile" />
554 <move file=
"output\doxygen\html\TortoiseAPI.chm" tofile=
"output\TortoiseGitAPI.chm" overwrite=
"true" />
555 <delete dir=
"output\doxygen" />
556 <delete file=
"Doxyfile" />