build-using-dita-command.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 2020"><meta name="DC.rights.owner" content="(C) Copyright 2020"><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, command, using"><meta name="keywords" content="macOS, command, dita, Linux, Windows, command, using"><meta name="DC.relation" scheme="URI" content="../topics/building-output.html"><meta name="DC.relation" scheme="URI" content="../topics/using-dita-properties-file.html"><meta name="DC.relation" scheme="URI" content="../topics/migrating-ant-to-dita.html"><meta name="DC.relation" scheme="URI" content="../topics/using-project-files.html"><meta name="DC.relation" scheme="URI" content="../parameters/dita-command-arguments.html"><meta name="DC.relation" scheme="URI" content="../topics/dita-command-help.html"><meta name="DC.relation" scheme="URI" content="../parameters/parameters_intro.html"><meta name="DC.relation" scheme="URI" content="../parameters/internal-ant-properties.html"><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><li><a href="../index.html">DITA Open Toolkit 3.5</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../topics/installing-client.html">Installing DITA-OT</a></li><li><a href="../topics/building-output.html">Building output</a><ul><li class="active"><a href="../topics/build-using-dita-command.html">Using the dita command</a><ul><li><a href="../topics/using-dita-properties-file.html">Using a properties file</a></li><li><a href="../topics/migrating-ant-to-dita.html">Migrating Ant builds</a></li><li><a href="../topics/using-project-files.html">Using a project file</a></li></ul></li><li><a href="../topics/using-docker-images.html">Using Docker images</a></li><li><a href="../topics/publishing-with-ant.html">Using Ant</a></li><li><a href="../reference/java-api.html">Using the Java API</a></li></ul></li><li><a href="../topics/input-formats.html">Authoring formats</a></li><li><a href="../topics/output-formats.html">Output formats</a></li><li><a href="../parameters/index.html">Parameters</a></li><li><a href="../topics/html-customization.html">Customizing HTML</a></li><li><a href="../topics/pdf-customization.html">Customizing PDF</a></li><li><a href="../topics/adding-plugins.html">Adding plug-ins</a></li><li><a href="../topics/custom-plugins.html">Creating plug-ins</a></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a></li><li><a href="../topics/dita-and-dita-ot-resources.html">Resources</a></li></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><div class="tasklabel"><h2 class="sectiontitle tasklabel">Procedure</h2></div><div class="li step p">
  11. <span class="ph cmd">At the command-line prompt, enter the following command:</span>
  12. <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>
  13. <p class="p">where:</p>
  14. <ul class="ul">
  15. <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
  16. process.</li>
  17. <li class="li">
  18. <p class="p">
  19. <var class="keyword varname">format</var> is the output format (transformation type). This argument corresponds to the
  20. common parameter <span class="keyword parmname">transtype</span>. Use the same values as for the
  21. <span class="keyword parmname">transtype</span> build parameter, for example <span class="keyword option">html5</span> or
  22. <span class="keyword option">pdf</span>. </p>
  23. <div class="p" id="using-command-line-tool__d652e292">You can create plug-ins to add new output formats; by default, the following values are
  24. available:
  25. <ul class="ul">
  26. <li class="li"><span class="keyword option">dita</span></li>
  27. <li class="li"><span class="keyword option">eclipsehelp</span></li>
  28. <li class="li"><span class="keyword option">html5</span></li>
  29. <li class="li"><span class="keyword option">htmlhelp</span></li>
  30. <li class="li"><span class="keyword option">markdown</span>, <span class="keyword option">markdown_gitbook</span>, and
  31. <span class="keyword option">markdown_github</span></li>
  32. <li class="li"><span class="keyword option">pdf</span></li>
  33. <li class="li"><span class="keyword option">xhtml</span></li>
  34. </ul>
  35. <div class="note tip note_tip"><span class="note__title">Tip:</span> See
  36. <a class="xref" href="output-formats.html" title="DITA Open Toolkit ships with several core transformations that convert DITA content to different output formats. Additional formats are available from the plug-in registry at dita-ot.org/plugins.">DITA-OT transformations (output formats)</a> for sample command line syntax and more information on each
  37. transformation. </div>
  38. </div>
  39. </li>
  40. <li class="li">[<var class="keyword varname">options</var>] include the following optional build parameters:
  41. <dl class="dl parml">
  42. <dt class="dt pt dlterm">
  43. <span class="keyword parmname">--debug</span></dt>
  44. <dt class="dt pt dlterm">
  45. <span class="keyword parmname">-d</span>
  46. </dt>
  47. <dd class="dd pd">Debug logging prints considerably more additional information. The debug log includes all information from
  48. the verbose log, plus details on Java classes, additional Ant properties and overrides, preprocessing
  49. filters, parameters, and stages, and the complete build sequence. Debug logging requires additional
  50. resources and can slow down the build process, so it should only be enabled when further details are
  51. required to diagnose problems.</dd>
  52. <dt class="dt pt dlterm">
  53. <span class="keyword parmname">--output</span>=<var class="keyword varname">dir</var></dt>
  54. <dt class="dt pt dlterm">
  55. <span class="keyword parmname">-o</span>
  56. <var class="keyword varname">dir</var>
  57. </dt>
  58. <dd class="dd pd" id="using-command-line-tool__d652e387">
  59. <p class="p">Specifies the path of the output directory; the path can be absolute or relative to the current
  60. directory.</p>
  61. <p class="p">This argument corresponds to the common parameter <span class="keyword parmname">output.dir</span>. By default, the output
  62. is written to the <span class="ph filepath">out</span> subdirectory of the current directory.</p>
  63. </dd>
  64. <dt class="dt pt dlterm">
  65. <span class="keyword parmname">--filter</span>=<var class="keyword varname">files</var>
  66. </dt>
  67. <dd class="dd pd">Specifies filter file(s) used to include, exclude, or flag content. </dd>
  68. <dd class="dd pd ddexpand">
  69. <p class="p">This argument corresponds to the common parameter <span class="keyword parmname">args.filter</span>. Relative paths are
  70. resolved against the current directory and internally converted to absolute paths.</p>
  71. <div class="note note note_note"><span class="note__title">Note:</span>
  72. <p class="p">To specify multiple filter files, use the system path separator character to delimit individual file
  73. paths (semicolon ‘<code class="ph codeph">;</code>’ on Windows, and colon ‘<code class="ph codeph">:</code>’ on macOS and Linux) and
  74. wrap the value in quotes:</p>
  75. <p class="p"><code class="ph codeph">--filter="filter1.ditaval;filter2.ditaval;filter3.ditaval"</code></p>
  76. <p class="p">DITAVAL files are evaluated in the order specified, so conditions specified in the first file take
  77. precedence over matching conditions specified in later files, just as conditions at the start of a
  78. DITAVAL document take precedence over matching conditions later in the same document.</p>
  79. </div>
  80. </dd>
  81. <dt class="dt pt dlterm">
  82. <span class="keyword parmname">--force</span>
  83. </dt>
  84. <dd class="dd pd">Force-install an existing plug-in.</dd>
  85. <dd class="dd pd ddexpand">Passed as an additional option to the installation subcommand: <span class="keyword cmdname">dita
  86. install</span>&nbsp;<var class="keyword varname">plug-in-zip</var>&nbsp;<span class="keyword parmname">--force</span></dd>
  87. <dt class="dt pt dlterm">
  88. <span class="keyword parmname">--help</span></dt>
  89. <dt class="dt pt dlterm">
  90. <span class="keyword parmname">-h</span>
  91. </dt>
  92. <dd class="dd pd">Print a list of available arguments, options, and subcommands.</dd>
  93. <dt class="dt pt dlterm">
  94. <span class="keyword parmname">--logfile</span>=<var class="keyword varname">file</var></dt>
  95. <dt class="dt pt dlterm">
  96. <span class="keyword parmname">-l</span>
  97. <var class="keyword varname">file</var>
  98. </dt>
  99. <dd class="dd pd">Write logging messages to a file.</dd>
  100. <dt class="dt pt dlterm">
  101. <span class="keyword parmname">--parameter</span>=<var class="keyword varname">value</var></dt>
  102. <dt class="dt pt dlterm">
  103. <span class="keyword parmname">-D</span><var class="keyword varname">parameter</var>=<var class="keyword varname">value</var>
  104. </dt>
  105. <dd class="dd pd">Specify a value for a DITA-OT or Ant build parameter.
  106. <p class="p">The GNU-style <span class="keyword parmname">--parameter</span>=<var class="keyword varname">value</var> form is only available for
  107. parameters that are configured in the plug-in configuration file; the Java-style <span class="keyword parmname">-D</span>
  108. form can also be used to specify additional non-configured parameters or set system properties.</p>
  109. <p class="p">Parameters not implemented by the specified transformation type or referenced in a
  110. <span class="ph filepath">.properties</span> file are ignored.</p>
  111. <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
  112. files is not consistent, set <span class="keyword option">args.input.dir</span> with the <span class="keyword cmdname">dita</span> command and
  113. reference its value with <code class="ph codeph">${args.input.dir}</code> in your <span class="ph filepath">.properties</span> file.
  114. </div></dd>
  115. <dt class="dt pt dlterm">
  116. <span class="keyword parmname">--propertyfile</span>=<var class="keyword varname">file</var>
  117. </dt>
  118. <dd class="dd pd">Use build parameters defined in the referenced <span class="ph filepath">.properties</span> file.
  119. <p class="p">Build parameters specified on the command line override those set in the <span class="ph filepath">.properties</span>
  120. file.</p></dd>
  121. <dt class="dt pt dlterm">
  122. <span class="keyword parmname">--resource</span>=<var class="keyword varname">file</var>
  123. </dt>
  124. <dt class="dt pt dlterm">
  125. <span class="keyword parmname">-r</span>
  126. <var class="keyword varname">file</var>
  127. </dt>
  128. <dd class="dd pd">Process input with additional resources.
  129. <div class="p">For example, to process a single topic file with a map that contains key definitions, use a command like
  130. this:
  131. <pre class="pre codeblock"><code><span class="keyword cmdname">dita</span> <span class="keyword parmname">--input</span>=<span class="ph filepath">topic.dita</span> <span class="keyword parmname">--resource</span>=<span class="ph filepath">keys.ditamap</span> <span class="keyword parmname">--format</span>=<span class="keyword option">html5</span></code></pre>
  132. </div></dd>
  133. <dt class="dt pt dlterm">
  134. <span class="keyword parmname">--temp</span>=<var class="keyword varname">dir</var></dt>
  135. <dt class="dt pt dlterm">
  136. <span class="keyword parmname">-t</span>
  137. <var class="keyword varname">dir</var>
  138. </dt>
  139. <dd class="dd pd">Specifies the location of the temporary directory.</dd>
  140. <dd class="dd pd ddexpand">This argument corresponds to the common parameter <span class="keyword parmname">dita.temp.dir</span>.</dd>
  141. <dt class="dt pt dlterm">
  142. <span class="keyword parmname">--verbose</span></dt>
  143. <dt class="dt pt dlterm">
  144. <span class="keyword parmname">-v</span>
  145. </dt>
  146. <dd class="dd pd">Verbose logging prints additional information to the console, including directory settings, effective
  147. values for Ant properties, input/output files, and informational messages to assist in troubleshooting.</dd>
  148. </dl></li>
  149. </ul></div>
  150. <div class="itemgroup stepresult">
  151. <p class="p">If processing is successful, nothing is printed in the terminal window. The built output is written to the
  152. specified output directory (by default, in the <span class="ph filepath">out</span> subdirectory of the current
  153. directory).</p>
  154. <div class="note tip note_tip" id="using-command-line-tool__d652e711"><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
  155. <span class="keyword cmdname">dita</span> command from any location on the file system without typing the path.
  156. </div>
  157. </div>
  158. </div></section>
  159. <section class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
  160. <p class="p">For example, from <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span>, run:</p>
  161. <div class="p">
  162. <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> \
  163. <span class="keyword parmname">--output</span>=<span class="ph filepath">output/sequence</span> \
  164. <span class="keyword parmname">--args.input.dir</span>=<span class="ph filepath"><var class="keyword varname">/absolute/path/to/dita-ot-dir</var>/docsrc/samples</span> \
  165. <span class="keyword parmname">--propertyfile</span>=<span class="ph filepath">properties/sequence-html5.properties</span></code></pre>
  166. </div>
  167. <p class="p">This builds <span class="ph filepath">sequence.ditamap</span> to HTML5 output in <span class="ph filepath">output/sequence</span> using
  168. the following additional parameters specified in the <span class="ph filepath">properties/sequence-html5.properties</span>
  169. file:</p>
  170. <div class="p">
  171. <pre class="pre codeblock language-properties normalize-space show-line-numbers show-whitespace"><code># Directory that contains the custom .css file:
  172. args.cssroot = ${args.input.dir}/css/
  173. # Custom .css file used to style output:
  174. args.css = style.css
  175. # Copy the custom .css file to the output directory:
  176. args.copycss = yes
  177. # Location of the copied .css file relative to the output:
  178. args.csspath = branding
  179. # Generate a full navigation TOC in topic pages:
  180. nav-toc = full</code></pre>
  181. </div>
  182. </section>
  183. <section class="section postreq"><div class="tasklabel"><h2 class="sectiontitle tasklabel">What to do next</h2></div>
  184. <p class="p">Usually, you will want to specify a set of reusable build parameters in a
  185. <span class="ph filepath">.properties</span> file.</p>
  186. </section>
  187. </div>
  188. <nav role="navigation" class="related-links"><ul class="ullinks"><li class="link ulchildlink"><strong><a href="../topics/using-dita-properties-file.html">Setting build parameters with .properties files</a></strong><br>Usually, DITA builds require setting a number of parameters that do not change frequently. You can reference a set of build parameters defined in a <span class="ph filepath">.properties</span> file when building output with the <span class="keyword cmdname">dita</span> command. If needed, you can override any parameter by specifying it explicitly as an argument to the <span class="keyword cmdname">dita</span> command.</li><li class="link ulchildlink"><strong><a href="../topics/migrating-ant-to-dita.html">Migrating Ant builds to use the dita command</a></strong><br>Although DITA Open Toolkit still supports Ant builds, switching to the <span class="keyword cmdname">dita</span> command offers a simpler command interface, sets all required environment variables and allows you to run DITA-OT without setting up anything beforehand.</li><li class="link ulchildlink"><strong><a href="../topics/using-project-files.html">Publishing with project files</a></strong><br><span class="ph">DITA-OT 3.4 introduces new project files to define publication projects with multiple deliverables. Projects specify a context, output folder, and publication for each deliverable. A re-usable context groups source files and filters, and a publication defines an output format with transformation parameters. You can pass a project file to the <span class="keyword cmdname">dita</span> command to publish multiple deliverables at once.</span></li></ul><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/building-output.html" title="You can use the dita command-line tool, Ant, or the Java API to transform DITA content to the various output formats that DITA Open Toolkit supports.">Building output</a></div></div><div class="linklist reltasks"><strong>Related tasks</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="../topics/dita-command-help.html" title="You can access a list of supported parameters for the dita command by passing the --help option on the command line.">Accessing help for the dita command</a></li></ul></div><div class="linklist relref"><strong>Related reference</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="../parameters/dita-command-arguments.html" title="The dita command takes mandatory arguments to process DITA content. Subcommands can be used to manage plug-ins, or print information about the current configuration. A series of options are available to modify the command behavior or specify additional configuration parameters.">Arguments and options for the dita command</a></li><li class="linklist"><a class="link" href="../parameters/parameters_intro.html" title="Certain parameters apply to all DITA-OT transformations. Other parameters are common to the HTML-based transformations. Some parameters apply only to specific transformation types. These parameters can be passed as options to the dita command using the --parameter=value syntax or included in build scripts as Ant properties.">DITA-OT parameters</a></li><li class="linklist"><a class="link" href="../parameters/internal-ant-properties.html" title="Reference list of Ant properties used by DITA-OT internally.">Internal Ant properties</a></li></ul></div></nav></article></main></body></html>