using-dita-command.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!DOCTYPE html
  2. SYSTEM "about:legacy-compat">
  3. <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2019"><meta name="DC.rights.owner" content="(C) Copyright 2019"><meta name="DC.type" content="task"><meta name="description" content="You can generate output using the dita command-line tool. Build parameters can be specified on the command line or with .properties files."><meta name="DC.subject" content="macOS, command, dita, Linux, Windows, using"><meta name="keywords" content="macOS, command, dita, Linux, Windows, using"><meta name="DC.format" content="HTML5"><meta name="DC.identifier" content="using-command-line-tool"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>Building output using the dita command</title></head><body id="using-command-line-tool"><header role="banner"><div class="header">
  4. <p>DITA Open Toolkit</p>
  5. <hr>
  6. </div></header><nav role="toc"><ul></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1">
  7. <h1 class="title topictitle1" id="ariaid-title1">Building output using the <span class="keyword cmdname">dita</span> command</h1>
  8. <div class="body taskbody"><p class="shortdesc">You can generate output using the <span class="keyword cmdname">dita</span> command-line tool. Build parameters can be
  9. specified on the command line or with <span class="ph filepath">.properties</span> files.</p>
  10. <section class="section context"><div class="tasklabel"><h2 class="sectiontitle tasklabel">About this task</h2></div>The DITA-OT client is a command-line tool with no graphical user interface. To verify
  11. that your installation works correctly, you can build output using the sample files included in the distribution
  12. package.</section>
  13. <section><div class="tasklabel"><h2 class="sectiontitle tasklabel">Procedure</h2></div><ol class="ol steps"><li class="li step stepexpand">
  14. <span class="ph cmd">Open a terminal window by typing the following in the search bar:</span>
  15. <div class="itemgroup info">
  16. <ul class="ul">
  17. <li class="li">On Linux and macOS, type <kbd class="ph userinput">Terminal</kbd>.</li>
  18. <li class="li">On Windows, type <kbd class="ph userinput">Command Prompt</kbd>.</li>
  19. </ul>
  20. </div>
  21. </li><li class="li step stepexpand">
  22. <span class="ph cmd">At the command-line prompt, enter the following command:</span>
  23. <div class="itemgroup info"><pre class="pre codeblock"><code><span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/bin/<span class="keyword cmdname">dita</span></span> <span class="keyword parmname">--input</span>=<var class="keyword varname">input-file</var> <span class="keyword parmname">--format</span>=<var class="keyword varname">format</var> <span class="ph">[<var class="keyword varname">options</var>]</span></code></pre>
  24. <p class="p">where:</p>
  25. <ul class="ul">
  26. <li class="li"><span class="ph filepath"><var class="keyword varname">dita-ot-dir</var></span> is the DITA-OT installation directory.</li><li class="li"><var class="keyword varname">input-file</var> is the DITA map or DITA file that you want to
  27. process.</li><li class="li">
  28. <p class="p" id="using-command-line-tool__d12e189">
  29. <var class="keyword varname">format</var> is the output format (transformation type).
  30. This argument corresponds to the common parameter
  31. <span class="keyword parmname">transtype</span>.
  32. Use the same values as for the <span class="keyword parmname">transtype</span> build
  33. parameter, for example <span class="keyword option">html5</span> or <span class="keyword option">pdf</span>.
  34. </p>
  35. </li>
  36. <li class="li"><span class="ph filepath"><var class="keyword varname">dita-ot-dir</var></span> is the DITA-OT installation directory.</li><li class="li"><var class="keyword varname">input-file</var> is the DITA map or DITA file that you want to
  37. process.</li>
  38. <li class="li">
  39. <p class="p">
  40. <var class="keyword varname">format</var> is the output format (transformation type).
  41. This argument corresponds to the common parameter
  42. <span class="keyword parmname">transtype</span>.
  43. Use the same values as for the <span class="keyword parmname">transtype</span> build
  44. parameter, for example <span class="keyword option">html5</span> or <span class="keyword option">pdf</span>.
  45. </p>
  46. <div class="p" id="using-command-line-tool__d12e228">You can create plug-ins to add new output formats; by default, the following values are
  47. available:
  48. <ul class="ul">
  49. <li class="li"><span class="keyword option">dita</span></li>
  50. <li class="li"><span class="keyword option">eclipsehelp</span></li>
  51. <li class="li"><span class="keyword option">html5</span></li>
  52. <li class="li"><span class="keyword option">htmlhelp</span></li>
  53. <li class="li"><span class="keyword option">markdown</span>, <span class="keyword option">markdown_gitbook</span>, and
  54. <span class="keyword option">markdown_github</span></li>
  55. <li class="li"><span class="keyword option">pdf</span></li>
  56. <li class="li"><span class="keyword option">tocjs</span></li>
  57. <li class="li"><span class="keyword option">troff</span></li>
  58. <li class="li"><span class="keyword option">xhtml</span></li>
  59. </ul>
  60. <div class="note tip note_tip"><span class="note__title">Tip:</span> See <a class="xref" href="../resources/../topics/output-formats.html" title="DITA Open Toolkit ships with several core transformations that generate different output formats from DITA content. Each transformation represents an implementation of the processing that is defined by OASIS in the DITA specification.">DITA-OT transformations (output formats)</a> for sample command line syntax and more information
  61. on each transformation.
  62. </div>
  63. </div>
  64. </li>
  65. <li class="li">[<var class="keyword varname">options</var>] include the following optional build parameters:
  66. <dl class="dl parml">
  67. <dt class="dt pt dlterm">
  68. <span class="keyword parmname">--output</span>=<var class="keyword varname">dir</var></dt>
  69. <dt class="dt pt dlterm">
  70. <span class="keyword parmname">-o</span>
  71. <var class="keyword varname">dir</var>
  72. </dt>
  73. <dd class="dd pd" id="using-command-line-tool__d12e314">
  74. <p class="p">Specifies the path of the output directory; the path can be absolute or relative to the current
  75. directory.</p>
  76. <p class="p">This argument corresponds to the common parameter <span class="keyword parmname">output.dir</span>. By default, the output
  77. is written to the <span class="ph filepath">out</span> subdirectory of the current directory.</p>
  78. </dd>
  79. <dt class="dt pt dlterm">
  80. <span class="keyword parmname">--filter</span>=<var class="keyword varname">files</var>
  81. </dt>
  82. <dd class="dd pd">Specifies filter file(s) used to include, exclude, or flag content. </dd>
  83. <dd class="dd pd ddexpand">
  84. <p class="p">This argument corresponds to the common parameter <span class="keyword parmname">args.filter</span>. Relative paths are
  85. resolved against the current directory and internally converted to absolute paths.</p>
  86. <div class="note note note_note"><span class="note__title">Note:</span>
  87. <p class="p">To specify multiple filter files, use the system path separator character to delimit individual file
  88. paths (semicolon ‘<code class="ph codeph">;</code>’ on Windows, and colon ‘<code class="ph codeph">:</code>’ on macOS and Linux) and
  89. wrap the value in quotes:</p>
  90. <p class="p"><code class="ph codeph">--filter="filter1.ditaval;filter2.ditaval;filter3.ditaval"</code></p>
  91. <p class="p">DITAVAL files are evaluated in the order specified, so conditions specified in the first file take
  92. precedence over matching conditions specified in later files, just as conditions at the start of a
  93. DITAVAL document take precedence over matching conditions later in the same document.</p>
  94. </div>
  95. </dd>
  96. <dt class="dt pt dlterm">
  97. <span class="keyword parmname">--force</span>
  98. </dt>
  99. <dd class="dd pd">Force-install an existing plug-in.</dd>
  100. <dd class="dd pd ddexpand">Passed as an additional option to the installation command:
  101. <span class="keyword cmdname">dita</span>&nbsp;<span class="keyword parmname">--install</span>=<var class="keyword varname">plug-in-zip</var>&nbsp;<span class="keyword parmname">--force</span></dd>
  102. <dt class="dt pt dlterm">
  103. <span class="keyword parmname">--temp</span>=<var class="keyword varname">dir</var></dt>
  104. <dt class="dt pt dlterm">
  105. <span class="keyword parmname">-t</span>
  106. <var class="keyword varname">dir</var>
  107. </dt>
  108. <dd class="dd pd">Specifies the location of the temporary directory.</dd>
  109. <dd class="dd pd ddexpand">This argument corresponds to the common parameter <span class="keyword parmname">dita.temp.dir</span>.</dd>
  110. <dt class="dt pt dlterm">
  111. <span class="keyword parmname">--verbose</span></dt>
  112. <dt class="dt pt dlterm">
  113. <span class="keyword parmname">-v</span>
  114. </dt>
  115. <dd class="dd pd">Verbose logging prints additional information to the console, including directory settings, effective
  116. values for Ant properties, input/output files, and informational messages to assist in troubleshooting.</dd>
  117. <dt class="dt pt dlterm">
  118. <span class="keyword parmname">--debug</span></dt>
  119. <dt class="dt pt dlterm">
  120. <span class="keyword parmname">-d</span>
  121. </dt>
  122. <dd class="dd pd">Debug logging prints considerably more additional information. The debug log includes all information from
  123. the verbose log, plus details on Java classes, additional Ant properties and overrides, preprocessing
  124. filters, parameters, and stages, and the complete build sequence. Debug logging requires additional
  125. resources and can slow down the build process, so it should only be enabled when further details are
  126. required to diagnose problems.</dd>
  127. <dt class="dt pt dlterm">
  128. <span class="keyword parmname">--logfile</span>=<var class="keyword varname">file</var></dt>
  129. <dt class="dt pt dlterm">
  130. <span class="keyword parmname">-l</span>
  131. <var class="keyword varname">file</var>
  132. </dt>
  133. <dd class="dd pd">Write logging messages to a file.</dd>
  134. <dt class="dt pt dlterm">
  135. <span class="keyword parmname">--parameter</span>=<var class="keyword varname">value</var></dt>
  136. <dt class="dt pt dlterm">
  137. <span class="keyword parmname">-D</span><var class="keyword varname">parameter</var>=<var class="keyword varname">value</var>
  138. </dt>
  139. <dd class="dd pd">Specify a value for a DITA-OT or Ant build parameter.
  140. <p class="p">The GNU-style <span class="keyword parmname">--parameter</span>=<var class="keyword varname">value</var> form is only available for
  141. parameters that are configured in the plug-in configuration file; the Java-style <span class="keyword parmname">-D</span>
  142. form can also be used to specify additional non-configured parameters or set system properties.</p>
  143. <p class="p">Parameters not implemented by the specified transformation type or referenced in a
  144. <span class="ph filepath">.properties</span> file are ignored.</p><div class="note tip note_tip"><span class="note__title">Tip:</span> If you are building in different environments where the location of the input
  145. files is not consistent, set <span class="keyword option">args.input.dir</span> with the <span class="keyword cmdname">dita</span> command and
  146. reference its value with <code class="ph codeph">${args.input.dir}</code> in your <span class="ph filepath">.properties</span>
  147. file.
  148. </div></dd>
  149. <dt class="dt pt dlterm">
  150. <span class="keyword parmname">--propertyfile</span>=<var class="keyword varname">file</var>
  151. </dt>
  152. <dd class="dd pd">Use build parameters defined in the referenced <span class="ph filepath">.properties</span> file.
  153. <p class="p">Build parameters specified on the command line override those set in the <span class="ph filepath">.properties</span>
  154. file.</p></dd>
  155. </dl></li>
  156. </ul></div>
  157. <div class="itemgroup stepresult">
  158. <p class="p">If processing is successful, nothing is printed in the terminal window. The built output is written to the
  159. specified output directory (by default, in the <span class="ph filepath">out</span> subdirectory of the current
  160. directory).</p>
  161. <div class="note tip note_tip" id="using-command-line-tool__d12e590"><span class="note__title">Tip:</span> Add the absolute path for <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var></span><span class="ph filepath">/bin</span> to the <var class="keyword varname">PATH</var> environment variable to run the
  162. <span class="keyword cmdname">dita</span> command from any location on the file system without typing the path.
  163. </div>
  164. </div>
  165. </li></ol></section>
  166. <section class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
  167. <p class="p">Run from <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span>, the following command generates
  168. HTML5 output for the <span class="ph filepath">sequence.ditamap</span> file:</p>
  169. <pre class="pre codeblock"><code><span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/bin/<span class="keyword cmdname">dita</span></span> <span class="keyword parmname">--input</span>=<span class="ph filepath">sequence.ditamap</span> <span class="keyword parmname">--format</span>=<span class="keyword option">html5</span></code></pre>
  170. </section>
  171. <section class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
  172. <p class="p">For example, from <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span>, run:</p>
  173. <div class="p">
  174. <pre class="pre codeblock"><code><span class="keyword cmdname">dita</span> <span class="keyword parmname">--input</span>=<span class="ph filepath">sequence.ditamap</span> <span class="keyword parmname">--format</span>=<span class="keyword option">html5</span> \
  175. <span class="keyword parmname">--output</span>=<span class="ph filepath">output/sequence</span> \
  176. <span class="keyword parmname">--args.input.dir</span>=<span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span> \
  177. <span class="keyword parmname">--propertyfile</span>=<span class="ph filepath">properties/sequence-html5.properties</span></code></pre>
  178. </div>
  179. <p class="p">This builds <span class="ph filepath">sequence.ditamap</span> to HTML5 output in <span class="ph filepath">output/sequence</span> using
  180. the following additional parameters specified in the <span class="ph filepath">properties/sequence-html5.properties</span>
  181. file:</p>
  182. <div class="p">
  183. <pre class="pre codeblock language-properties normalize-space show-line-numbers show-whitespace"><code># Don't generate headings for sections within task topics:
  184. args.gen.task.lbl = NO
  185. # Directory that contains the custom .css file:
  186. args.cssroot = ${args.input.dir}/css/
  187. # Custom .css file used to style output:
  188. args.css = style.css
  189. # Copy the custom .css file to the output directory:
  190. args.copycss = yes
  191. # Location of the copied .css file relative to the output:
  192. args.csspath = branding
  193. # Generate a full navigation TOC in topic pages:
  194. nav-toc = full
  195. # Base name of the Table of Contents file:
  196. args.xhtml.toc = toc</code></pre>
  197. </div>
  198. </section>
  199. <section class="section postreq"><div class="tasklabel"><h2 class="sectiontitle tasklabel">What to do next</h2></div>
  200. <p class="p">Most builds require you to specify more options than are described in this topic.</p>
  201. <p class="p">Usually, you will want to specify a set of reusable build parameters in a
  202. <span class="ph filepath">.properties</span> file.</p>
  203. </section>
  204. </div>
  205. </article></main></body></html>