build_dita2htmlhelp.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?xml version="1.0" encoding="UTF-8"?><!--
  2. This file is part of the DITA Open Toolkit project.
  3. Copyright 2006 IBM Corporation
  4. See the accompanying LICENSE file for applicable license.
  5. --><project xmlns:dita="http://dita-ot.sourceforge.net" xmlns:if="ant:if" xmlns:unless="ant:unless" name="dita2htmlhelp">
  6. <target name="dita2htmlhelp" unless="noMap" depends="dita2htmlhelp.init, build-init, use-init.envhhcdir, use-init.hhcdir, preprocess2, htmlhelp.topics, htmlhelp.copy-image, copy-css">
  7. <antcall target="dita.map.htmlhelp"/>
  8. </target>
  9. <target name="dita2htmlhelp.init">
  10. <property name="html-version" value="html"/>
  11. <property name="temp.output.dir.name" value="temp_chm_dir"/>
  12. <property name="preprocess.copy-image.skip" value="true"/>
  13. </target>
  14. <target name="use-init.envhhcdir" if="env.HHCDIR">
  15. <available file="${env.HHCDIR}/hhc.exe" property="HTMLHelpCompiler" value="${env.HHCDIR}${file.separator}hhc.exe"/>
  16. </target>
  17. <target name="use-init.hhcdir" unless="env.HHCDIR">
  18. <condition property="hhc.dir" value="${env.ProgramFiles(x86)}\HTML Help Workshop" else="${env.ProgramFiles}\HTML Help Workshop">
  19. <available file="${env.ProgramFiles(x86)}\HTML Help Workshop" type="dir"/>
  20. </condition>
  21. <available file="${hhc.dir}/hhc.exe" property="HTMLHelpCompiler" value="${hhc.dir}${file.separator}hhc.exe"/>
  22. </target>
  23. <target name="htmlhelp.copy-image" description="Copy image files">
  24. <copy todir="${dita.output.dir}" failonerror="false">
  25. <ditafileset format="image"/>
  26. <jobmapper type="temp"/>
  27. </copy>
  28. </target>
  29. <target name="htmlhelp.topics" depends="xhtml.init, xhtml.image-metadata">
  30. <topics.html>
  31. </topics.html>
  32. </target>
  33. <target name="dita.map.htmlhelp" depends="dita.map.htmlhelp.init, dita.map.htmlhelp.hhp, dita.map.htmlhelp.hhc, dita.map.htmlhelp.hhk, dita.htmlhelp.convertlang, compile.HTML.Help"/>
  34. <target name="dita.map.htmlhelp.init" description="Init properties for HTMLHelp">
  35. <condition property="out.ext" value=".html">
  36. <not>
  37. <isset property="out.ext"/>
  38. </not>
  39. </condition>
  40. <property name="args.output.base" value="${dita.map.filename.root}"/>
  41. </target>
  42. <target name="dita.map.htmlhelp.hhp" depends="dita.map.htmlhelp.init" description="Build HTMLHelp HHP file">
  43. <local name="htmlhelp.hhp.output.dir"/>
  44. <condition property="htmlhelp.hhp.output.dir" value="${dita.output.dir}" else="${_dita.map.output.dir}">
  45. <isset property="inner.transform"/>
  46. </condition>
  47. <pipeline>
  48. <xslt destdir="${htmlhelp.hhp.output.dir}" style="${dita.plugin.org.dita.htmlhelp.dir}/xsl/map2hhp.xsl">
  49. <ditafileset input="true" processingRole="normal"/>
  50. <param name="OUTEXT" expression="${out.ext}" if:set="out.ext"/>
  51. <param name="HHCNAME" expression="${args.output.base}.hhc"/>
  52. <param name="INCLUDEFILE" expression="${args.htmlhelp.includefile}" if:set="args.htmlhelp.includefile"/>
  53. <param name="defaultLanguage" expression="${default.language}"/>
  54. <xmlcatalog refid="dita.catalog"/>
  55. <mapper type="merge" to="${args.output.base}.hhp"/>
  56. </xslt>
  57. </pipeline>
  58. </target>
  59. <target name="dita.map.htmlhelp.hhc" depends="dita.map.htmlhelp.init" description="Build HTMLHelp HHC file">
  60. <local name="htmlhelp.hhc.output.dir"/>
  61. <condition property="htmlhelp.hhc.output.dir" value="${dita.output.dir}" else="${_dita.map.output.dir}">
  62. <isset property="inner.transform"/>
  63. </condition>
  64. <pipeline>
  65. <xslt destdir="${htmlhelp.hhc.output.dir}" style="${dita.plugin.org.dita.htmlhelp.dir}/xsl/map2hhc.xsl">
  66. <ditafileset input="true" processingRole="normal"/>
  67. <param name="OUTEXT" expression="${out.ext}" if:set="out.ext"/>
  68. <param name="defaultLanguage" expression="${default.language}"/>
  69. <xmlcatalog refid="dita.catalog"/>
  70. <mapper type="merge" to="${args.output.base}.hhc"/>
  71. </xslt>
  72. </pipeline>
  73. </target>
  74. <target name="dita.map.htmlhelp.hhk" depends="dita.map.htmlhelp.init" description="Build HTMLHelp HHK file">
  75. <local name="htmlhelp.hhk.output.dir"/>
  76. <condition property="htmlhelp.hhk.output.dir" value="${dita.output.dir}" else="${_dita.map.output.dir}">
  77. <isset property="inner.transform"/>
  78. </condition>
  79. <pipeline message="Extract index term." inputmap="${user.input.file}">
  80. <module class="org.dita.dost.module.IndexTermExtractModule">
  81. <param name="output" location="${htmlhelp.hhk.output.dir}/${args.output.base}.hhk"/>
  82. <param name="targetext" value="${out.ext}"/>
  83. <param name="indextype" value="htmlhelp"/>
  84. <param name="indexclass" value="org.dita.dost.writer.CHMIndexWriter"/>
  85. <param name="encoding" value="${args.dita.locale}" if:set="args.dita.locale"/>
  86. <param name="defaultLanguage" expression="${default.language}"/>
  87. </module>
  88. </pipeline>
  89. </target>
  90. <target name="dita.htmlhelp.convertlang">
  91. <taskdef name="check-lang" classname="org.dita.dost.ant.CheckLang"/>
  92. <taskdef name="convert-lang" classname="org.dita.dost.ant.ConvertLang"/>
  93. <check-lang message="Check Language" basedir="${dita.dir}" tempdir="${dita.temp.dir}" inputmap="${user.input.file}" outputdir="${dita.output.dir}"/>
  94. <convert-lang message="Convert Language" basedir="${dita.dir}" outputdir="${dita.output.dir}" langcode="${htmlhelp.locale}"/>
  95. </target>
  96. <target name="compile.HTML.Help" if="HTMLHelpCompiler" description="Compile HTMLHelp output">
  97. <exec executable="${HTMLHelpCompiler}" failonerror="${failonerror}" failifexecutionfails="${failonerror}">
  98. <arg file="${dita.output.dir}/${args.output.base}.hhp"/>
  99. </exec>
  100. <copy todir="${output.dir}">
  101. <fileset dir="${dita.output.dir}" includes="*.chm"/>
  102. </copy>
  103. </target>
  104. </project>