BrowseRefs: Context menu enhancements
[TortoiseGit.git] / doc / doc.build
blob9a0c8f7305dbb677d77846c2e5499cc651cbbbab
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" />
23 <property name="nant.settings.currentframework" value="net-3.5" />
25 <include buildfile="doc.build.include"/>
27 <!-- ====================================================================== -->
28 <!-- Loop over all languages -->
29 <!-- ====================================================================== -->
31 <target name="all"
32 description="Loop over all languages, output formats and applications and build documentation"
33 depends="prepare" >
35 <foreach item="String" in="${languages}" delim="," property="lang.target">
36 <!-- language code for English (US) (default)-->
37 <property name="lang.target.code" value="1033" />
38 <property name="languagebuildfile" value="${path.user.xsl}/${lang.target}/lang.build" />
39 <if test="${file::exists(languagebuildfile)}" >
40 <include buildfile="${languagebuildfile}" />
41 </if>
42 <call target="doit" failonerror="${critical or lang.base==lang.target}"/>
43 </foreach>
44 </target>
46 <!-- ====================================================================== -->
47 <!-- Loop over all applications and output formats -->
48 <!-- ====================================================================== -->
50 <target name="doit">
52 <foreach item="String" in="${applications}" delim="," property="app">
53 <property name="doc.source.file" value="source/${lang.base}/${app}.xml"/>
54 <property name="doc.base.name" value="${app}_${lang.base}"/>
55 <property name="doc.base.work" value="output/${doc.base.name}"/>
57 <property name="doc.target.name" value="${app}_${lang.target}"/>
58 <property name="doc.target.work" value="output/${doc.target.name}"/>
59 <property name="doc.target.source" value="source/${lang.target}/${app}/${app}.xml"/>
60 <property name="pofiletotranslate" value="po/${app}_${lang.target}.po" />
62 <echo message="------------------------------------------------------------"/>
63 <echo message="Creating '${doc.target.name}' documentation"/>
65 <if test="${file::exists(pofiletotranslate)}" >
66 <call target="translate" unless="${lang.base==lang.target}" />
67 </if>
68 <if test="${lang.base==lang.target or file::exists(pofiletotranslate)}" >
69 <!-- update version info in version.xml -->
70 <call target="UpdateVersionInfo"/>
72 <call target="spellcheck" if="${property::exists('spellcheck') and spellcheck=='true'}"/>
73 <call target="copyimages"/>
75 <property name="xslt.source" value="${doc.target.source}"/>
76 <foreach item="String" in="${docformats}" delim="," property="docformat">
77 <call target="${docformat}"/>
78 </foreach>
79 </if>
80 </foreach>
81 </target>
83 <!-- ====================================================================== -->
84 <!-- ====================================================================== -->
86 <target name="clean" description="remove all generated files">
87 <if test="${cleanup == 'yes'}">
88 <delete dir="output" failonerror="false"/>
89 </if>
90 </target>
92 <!-- ====================================================================== -->
93 <!-- ====================================================================== -->
95 <target name="prepare" description="Create directories" depends="clean">
96 <mkdir dir="output"/>
97 <call target="prepare.custom" if="${target::exists('prepare.custom')}"/>
99 <!-- find the path to the fonts -->
100 <script language="C#">
101 <code>
102 <![CDATA[
103 public static void ScriptMain(Project project)
105 string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
106 string fontsPath = Path.GetDirectoryName(systemPath) + Path.DirectorySeparatorChar + "FONTS";
107 fontsPath = fontsPath.Replace('\\','/');
108 project.Properties.Add("fontpath", fontsPath );
111 </code>
112 </script>
114 <!-- ensure "Version" translation invariant -->
115 <copy file="source\${lang.base}\version.in" tofile="source\${lang.base}\version.xml" overwrite="true"/>
117 <!-- tune path to xsltproc.exe in aspell.bat -->
118 <copy file="Aspell/aspell.in" tofile="Aspell/aspell.bat" overwrite="true">
119 <filterchain>
120 <replacetokens begintoken="$" endtoken="$">
121 <token key="XSLTProcPath" value="${path.bin}" />
122 </replacetokens>
123 </filterchain>
124 </copy>
126 </target>
128 <!-- ====================================================================== -->
129 <!-- ====================================================================== -->
131 <target name="copyimages" description="Copy images">
132 <delete dir="${doc.target.work}/images" failonerror="false"/>
133 <mkdir dir="${doc.target.work}/images"/>
134 <copy todir="${doc.target.work}/images">
135 <fileset basedir="images/${lang.base}">
136 <include name="*"/>
137 </fileset>
138 </copy>
140 <copy todir="${doc.target.work}/images" unless="${lang.base==lang.target}" overwrite="true">
141 <fileset basedir="images/${lang.target}">
142 <include name="*"/>
143 </fileset>
144 </copy>
145 </target>
147 <!-- ====================================================================== -->
148 <!-- ====================================================================== -->
150 <target name="uptodate" description="Check whether the given target is up to date">
152 <echo message="Checking if '${file.target}' is up to date"/>
153 <uptodate property="file.target.uptodate">
154 <sourcefiles>
155 <include name="source/${lang.target}/${app}/**/*.xml"/>
156 <include name="source/${lang.target}/pubdate.xml"/>
157 <include name="source/${lang.target}/glossary.xml"/>
158 <include name="source/${lang.target}/wishlist.xml"/>
159 <include name="source/${lang.target}/version.in"/>
160 </sourcefiles>
161 <targetfiles>
162 <include name="${file.target}"/>
163 </targetfiles>
164 </uptodate>
165 <if test="${file.target.uptodate}">
166 <echo message="Up to date"/>
167 </if>
168 </target>
170 <!-- ====================================================================== -->
171 <!-- Run xsltproc with the defined parameters -->
172 <!-- ====================================================================== -->
174 <target name="xsltproc" description="Run xsltproc with the defined parameters">
175 <echo message="Processing XML Source" />
177 <!-- Check whether a language specific xsl file exists and use it -->
178 <!-- if none is found, load XSL file from default location. -->
179 <property name="xslt.file.lang" value="${path.user.xsl}/${lang.target}/${xslt.file}" />
180 <property name="xslt.file" value="${xslt.file.lang}" if="${file::exists(xslt.file.lang)}"/>
181 <property name="xslt.file" value="${path.user.xsl}/${xslt.file}" unless="${file::exists(xslt.file.lang)}"/>
183 <echo message="Stylesheet: ${xslt.file}" />
184 <echo message="Parameters: ${xslt.params}" />
185 <exec program="xsltproc"
186 commandline="${xslt.params} --output ${xslt.target} ${xslt.file} ${xslt.source}"
187 basedir="${path.bin}"
188 verbose="false"/>
189 </target>
191 <!-- ====================================================================== -->
192 <!-- Profile source into a single file -->
193 <!-- ====================================================================== -->
195 <target name="profile" description="Profile source into a single file" >
197 <call target="uptodate"/>
199 <if test="${not file.target.uptodate}">
200 <property name="xslt.params" value="${xsl.profile.params}"/>
201 <property name="xslt.file" value="${xsl.profile.file}"/>
202 <property name="xslt.target" value="${file.target}.tmp"/>
204 <echo message="Profiling into: ${file.target}"/>
205 <call target="xsltproc"/>
207 <!-- Removes the moreinfo="" attributes added by xsltproc -->
208 <move file="${xslt.target}" tofile="${file.target}" overwrite="true">
209 <filterchain>
210 <replacestring from=" moreinfo=&quot;none&quot;" to="" />
211 </filterchain>
212 </move>
213 </if>
214 </target>
216 <!-- ====================================================================== -->
217 <!-- Create po template for each application from sources -->
218 <!-- ====================================================================== -->
220 <target name="potfile" description="Create po template from sources">
221 <property name="lang.target" value="${lang.base}"/>
223 <!-- ensure "Version" translation invariant -->
224 <copy file="source\${lang.base}\version.in" tofile="source\${lang.base}\version.xml" overwrite="true"/>
226 <foreach item="String" in="${potemplates}" delim="," property="app">
228 <property name="potfile" value="po/${app}.pot" />
229 <property name="xslt.source" value="source/${lang.base}/${app}/${app}.xml"/>
230 <property name="file.target" value="source/${app}_${lang.base}.xml"/>
232 <echo message="------------------------------------------------------------"/>
233 <echo message="Checking if ${potfile} is up to date"/>
235 <call target="profile" />
237 <if test="${not file::up-to-date(file.target, potfile)}">
238 <echo message="Creating po template from sources"/>
239 <exec program="python"
240 commandline="xml2po.py -e -o ${potfile}.tmp ${file.target}"
241 verbose="false"/>
243 <!-- Adjust path to source file -->
244 <move file="${potfile}.tmp" tofile="${potfile}" overwrite="true">
245 <filterchain>
246 <replacestring from="#: ${file.target}" to="#: ../${file.target}" />
247 </filterchain>
248 </move>
249 </if>
251 <echo message="" />
252 </foreach>
253 </target>
255 <!-- ====================================================================== -->
256 <!-- Create translated source files -->
257 <!-- ====================================================================== -->
259 <target name="translate" description="Create translated source file">
260 <property name="lang.pofile" value="po/${app}_${lang.target}.po"/>
262 <echo message="Translating: '${app} ${lang.target}' This may take a few minutes"/>
264 <exec program="msgfmt"
265 commandline="${lang.pofile} -o ${lang.target}.mo"
266 basedir="${path.gettext}"
267 verbose="false"/>
269 <foreach item="File" property="file.base">
270 <in>
271 <items>
272 <include name="source/${lang.base}/${app}/**/*.xml"/>
273 <include name="source/${lang.base}/pubdate.xml"/>
274 <include name="source/${lang.base}/glossary.xml"/>
275 <include name="source/${lang.base}/wishlist.xml"/>
276 <include name="source/${lang.base}/version.in"/>
277 </items>
278 </in>
279 <do>
280 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
282 <uptodate property="file.target.uptodate">
283 <sourcefiles>
284 <include name="${file.base}"/>
285 <include name="${lang.pofile}"/>
286 </sourcefiles>
287 <targetfiles>
288 <include name="${file.target}"/>
289 </targetfiles>
290 </uptodate>
292 <if test="${not file.target.uptodate}">
294 <echo message="Translating: ${path::get-file-name(file.target)}"/>
295 <property name="dir.target" value="${path::get-directory-name(file.target)}"/>
296 <mkdir dir="${dir.target}" unless="${directory::exists(dir.target)}"/>
297 <exec program="python"
298 commandline='xml2po.py -t "${lang.target}.mo" -o "${file.target}" "${file.base}"'
299 verbose="false"/>
300 </if>
302 </do>
303 </foreach>
305 <!--
306 <foreach item="File" property="file.base">
307 <in>
308 <items refid="files.exclude" />
309 </in>
310 <do>
311 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
312 <copy file="${file.base}" tofile="${file.target}" overwrite="true"/>
313 </do>
314 </foreach>
317 <delete file="${lang.target}.mo"/>
318 </target>
320 <!-- ====================================================================== -->
321 <!-- Try to update version info in the version file -->
322 <!-- ====================================================================== -->
324 <target name="UpdateVersionInfo" description="Updates the version file with version info">
326 <copy
327 file="source\${lang.target}\version.in"
328 tofile="source\${lang.target}\version.xml"
329 overwrite="true">
331 <filterchain>
332 <replacetokens begintoken="$" endtoken="$">
333 <token key="MajorVersion" value="${environment::get-variable('MajorVersion')}"/>
334 <token key="MinorVersion" value="${environment::get-variable('MinorVersion')}"/>
335 <token key="MicroVersion" value="${environment::get-variable('Microversion')}"/>
336 <!--
337 <token key="WCREV" value="${environment::get-variable('WCREV')}"/>
339 </replacetokens>
340 </filterchain>
341 </copy>
343 </target>
345 <!-- ====================================================================== -->
346 <!-- Run spellchecker on files -->
347 <!-- ====================================================================== -->
349 <target name="spellcheck" description="Run spellchecker on files">
350 <echo message="Spellchecking: '${app} ${lang.target}' This may take a few minutes"/>
351 <property name="spellcheck.log" value="ASpell/${app}_${lang.target}.log"/>
352 <mkdir dir="ASpell/${app}_${lang.target}"/>
354 <echo message="--- Spellchecking: '${lang.target}'"
355 file="${spellcheck.log}"
356 failonerror="false"/>
358 <copy file="Aspell/TortoiseGit.tmpl.pws" tofile="Aspell/Temp.pws" overwrite="true">
359 <filterchain>
360 <replacetokens begintoken="$" endtoken="$">
361 <token key="LANG" value="${lang.target}" />
362 </replacetokens>
363 </filterchain>
364 </copy>
366 <foreach item="File" property="file.base">
367 <in>
368 <items>
369 <include name="source/${lang.base}/${app}/**/*.xml"/>
370 <include name="source/${lang.base}/glossary.xml"/>
371 <include name="source/${lang.base}/wishlist.xml"/>
372 </items>
373 </in>
374 <do>
375 <property name="file.target" value="${string::replace(file.base,'\'+lang.base+'\','\'+lang.target+'\')}"/>
376 <property name="file.log" value="ASpell\${app}_${lang.target}\${path::get-file-name(file.target)}.log"/>
378 <uptodate property="file.target.uptodate">
379 <sourcefiles>
380 <include name="${file.target}"/>
381 <include name="ASpell/${lang.target}.pws"/>
382 <include name="ASpell/TortoiseGit.tmpl.pws"/>
383 </sourcefiles>
384 <targetfiles>
385 <include name="${file.log}"/>
386 </targetfiles>
387 </uptodate>
389 <if test="${not file.target.uptodate}">
390 <echo message="Checking: ${path::get-file-name(file.target)}"/>
391 <exec program="Aspell/aspell.bat"
392 commandline="${path.spellcheck} ${lang.target} ${file.target} ${file.log}"
393 failonerror="false"/>
394 </if>
395 <exec program="Aspell/append.bat"
396 commandline="${file.log} ${spellcheck.log}"/>
397 </do>
398 </foreach>
399 </target>
401 <!-- ====================================================================== -->
402 <!-- Create PDF documentation -->
403 <!-- ====================================================================== -->
405 <target name="pdf" description="Create PDF documentation">
407 <property name="file.target" value="output/${app}-${docverstring}-${lang.target}.pdf"/>
408 <call target="uptodate"/>
410 <if test="${not file.target.uptodate}">
411 <property name="xslt.params" value="${xsl.pdf.params}"/>
412 <property name="xslt.file" value="${xsl.pdf.file}"/>
413 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}.fo"/>
415 <call target="xsltproc" />
417 <property name="userconfig.langtemplate" value="${path.user.xsl}/${lang.target}/userconfig.template.xml" />
418 <property name="userconfig.lang" value="${path.user.xsl}/${lang.target}/userconfig.xml" />
420 <if test="${file::exists(userconfig.langtemplate)}">
421 <loadfile file="${userconfig.langtemplate}" property="configfile">
422 <filterchain>
423 <replacetokens begintoken="%" endtoken="%">
424 <token key="FONTSDIR" value="${fontpath}" />
425 </replacetokens>
426 </filterchain>
427 </loadfile>
428 <echo file="${userconfig.lang}" message="${configfile}" />
429 </if>
430 <property name="commandline" value="-q -fo ${xslt.target} -pdf ${file.target}"/>
431 <property name="commandline" value="-c ${userconfig.lang} ${commandline}" if="${file::exists(userconfig.lang)}"/>
433 <exec program="fop.bat"
434 commandline="${commandline}"
435 basedir="${path.fop}"
436 verbose="false"/>
437 </if>
438 </target>
440 <!-- ====================================================================== -->
441 <!-- Create CHM documentation -->
442 <!-- ====================================================================== -->
444 <target name="chm" description="Create CHM documentation">
446 <property name="file.target" value="${doc.target.work}.chm"/>
447 <call target="uptodate"/>
449 <if test="${not file.target.uptodate}">
450 <property name="xslt.params" value="${xsl.chm.params}"/>
451 <property name="xslt.file" value="${xsl.chm.file}"/>
452 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
454 <call target="xsltproc" />
456 <!-- The CHM helpcontext target resides in an external build file -->
457 <call target="help.prepare" if="${target::exists('help.prepare')}"/>
459 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
461 <exec program="SBAppLocale.exe"
462 commandline="${lang.target.code} ${path.bin}/hhc.exe ${doc.target.work}/htmlhelp.hhp"
463 basedir="${path.bin}"
464 resultproperty="result.hhc"
465 failonerror="false"
466 verbose="false"
467 timeout="600000" />
469 <copy file="${doc.target.work}/htmlhelp.chm" tofile="${file.target}"/>
470 </if>
471 <!--
472 <delete>
473 <fileset>
474 <include name="${doc.target.work}/*.*"/>
475 </fileset>
476 </delete>
478 </target>
480 <!-- ====================================================================== -->
481 <!-- Create HTML multi page documentation -->
482 <!-- ====================================================================== -->
483 <target name="html" description="Create HTML documentation" depends="">
485 <property name="file.target" value="${doc.target.work}/index.html"/>
486 <call target="uptodate"/>
488 <if test="${not file.target.uptodate}">
489 <property name="xslt.params" value="${xsl.htmlsingle.params}"/>
490 <property name="xslt.file" value="${xsl.htmlsingle.file}"/>
491 <property name="xslt.target" value="${doc.target.work}/${doc.target.name}"/>
493 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
494 <copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
496 <call target="xsltproc" />
498 </if>
499 </target>
501 <!-- ====================================================================== -->
502 <!-- Create HTML single page documentation -->
503 <!-- ====================================================================== -->
505 <target name="htmlsingle" description="Create HTML single page documentation" depends="">
507 <property name="file.target" value="${doc.target.work}/help-onepage.html"/>
508 <call target="uptodate"/>
510 <if test="${not file.target.uptodate}">
511 <property name="xslt.params" value="${xsl.html.params}"/>
512 <property name="xslt.file" value="${xsl.html.file}"/>
513 <property name="xslt.target" value="${file.target}"/>
515 <copy file="${path.user.css}/styles_chm.css" todir="${doc.target.work}"/>
516 <copy file="${path.user.css}/styles_html.css" todir="${doc.target.work}"/>
518 <call target="xsltproc" />
520 </if>
521 </target>
523 <!-- ====================================================================== -->
524 <!-- Create the API documentation -->
525 <!-- ====================================================================== -->
527 <target name="apidoc" depends="GitAPIdoc,TortoiseGitAPIdoc" />
529 <target name="GitAPIdoc">
530 <loadfile file="API\DoxyfileSVN" property="GitDoxyFile" />
531 <echo file="Doxyfile" message="${GitDoxyFile}" />
532 <echo file="Doxyfile" message="HHC_LOCATION=${environment::get-variable('HHLOC')}" append="true" />
533 <mkdir dir="output" />
534 <exec program="doxygen.exe">
535 <arg value="Doxyfile" />
536 </exec>
537 <move file="output\doxygen\html\GitAPI.chm" tofile="output\GitAPI.chm" overwrite="true" />
538 <delete dir="output\doxygen" />
539 <delete file="Doxyfile" />
540 </target>
542 <target name="TortoiseGitAPIdoc">
543 <loadfile file="API\Doxyfile" property="TortoiseGitDoxyFile" />
544 <echo file="Doxyfile" message="${TortoiseGitDoxyFile}" />
545 <echo file="Doxyfile" message="HHC_LOCATION=${environment::get-variable('HHLOC')}" append="true" />
546 <mkdir dir="output" />
547 <exec program="doxygen.exe">
548 <arg value="Doxyfile" />
549 </exec>
550 <move file="output\doxygen\html\TortoiseAPI.chm" tofile="output\TortoiseGitAPI.chm" overwrite="true" />
551 <delete dir="output\doxygen" />
552 <delete file="Doxyfile" />
553 </target>
555 </project>