plugins-registry.dita 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <topic id="plugin-registry">
  5. <title>Adding plug-ins via the registry</title>
  6. <titlealts>
  7. <navtitle>Plug-in registry</navtitle>
  8. </titlealts>
  9. <shortdesc><ph id="registry-summary">DITA-OT 3.2 supports a new plug-in registry that makes it easier to discover and
  10. install new plug-ins. The registry provides a searchable list of plug-ins at <xref keyref="site-plugin-registry"
  11. />.</ph></shortdesc>
  12. <prolog>
  13. <metadata>
  14. <keywords>
  15. <indexterm>PDF<indexterm>plug-in</indexterm></indexterm>
  16. <indexterm><cmdname>dita</cmdname> command<indexterm>plug-in registry</indexterm></indexterm>
  17. <indexterm>plug-ins<indexterm>registry</indexterm></indexterm>
  18. <indexterm>plug-ins<indexterm>installing</indexterm></indexterm>
  19. <indexterm>GitHub</indexterm>
  20. <indexterm>plug-ins<indexterm>URL</indexterm></indexterm>
  21. </keywords>
  22. </metadata>
  23. </prolog>
  24. <body>
  25. <section id="background">
  26. <p>In the past, installing plug-ins required you to either download a plug-in to your computer and provide the
  27. path to the plug-in archive (.zip file) or pass the URL of the plug-in distribution file to the
  28. <cmdname>dita</cmdname> command and let DITA-OT download the file. This required that you know the URL of the
  29. plug-in distribution package.</p>
  30. </section>
  31. <section id="using-the-registry">
  32. <title>Installing plug-ins from the registry</title>
  33. <p>With the registry, you can now search the list of available plug-ins at <xref keyref="site-plugin-registry"/>
  34. and install new plug-ins by name and optional version.</p>
  35. <p>Search the registry for a plug-in and install it by providing the plug-in name to the <cmdname>dita</cmdname>
  36. command.</p>
  37. <codeblock><cmdname>dita</cmdname> <parmname>--install</parmname>=<varname>&lt;plugin-name&gt;</varname></codeblock>
  38. <p>If the registry includes multiple versions of the same plug-in, you can specify the version to install as
  39. follows:</p>
  40. <codeblock><cmdname>dita</cmdname> <parmname>--install</parmname>=<varname>&lt;plugin-name&gt;@&lt;plugin-version&gt;</varname></codeblock>
  41. <p>If the plug-in requires other plug-ins, those are also installed recursively.</p>
  42. <p>For example, to revert PDF output to the legacy PDF2 layout that was the default in DITA-OT before 2.5, install
  43. the <filepath>org.dita.pdf2.legacy</filepath> plug-in as follows:</p>
  44. <codeblock><cmdname>dita</cmdname> <parmname>--install</parmname>=org.dita.pdf2.legacy</codeblock>
  45. <p>If a matching plug-in cannot be found, an error message will appear. Possible reasons for failure include:</p>
  46. <ul>
  47. <li>A plug-in with the specified name was not found in the registry</li>
  48. <li>A plug-in with the specified version was not found in the registry</li>
  49. <li>The specified plug-in version is not compatible with the installed DITA-OT version</li>
  50. <li>None of the available plug-in versions are compatible with the installed DITA-OT version</li>
  51. </ul>
  52. </section>
  53. <section id="publishing-to-registry"><title>Publishing plug-ins to the registry</title>
  54. <p>The contents of the DITA Open Toolkit plug-in registry are stored in a Git repository at <xref
  55. keyref="registry-repo"/>. New plug-ins or new versions can be added by sending a <xref keyref="pull-request"/>
  56. that includes a single new plug-in entry in JavaScript Object Notation (JSON) format.</p>
  57. <note>As for all other contributions to the project, pull requests to the registry must be signed off by passing
  58. the <codeph>--signoff</codeph> option to the <cmdname>git commit</cmdname> command to certify that you have the
  59. rights to submit this contribution. For more information on this process, see <xref keyref="signoff"/>.</note>
  60. <p>The version entries for each plug-in are stored in a file that is named after the plug-in ID as
  61. <codeph>&lt;plugin-name&gt;.json</codeph>. The file contains an array of entries with a pre-defined structure.
  62. You should have one entry for each supported version of the plug-in.</p>
  63. <table outputclass="table-hover" frame="none" colsep="0" rowsep="1">
  64. <title>Plug-in version entry structure</title>
  65. <tgroup cols="3">
  66. <colspec colwidth="1*"/>
  67. <colspec colwidth="1*"/>
  68. <colspec colwidth="3*"/>
  69. <thead>
  70. <row>
  71. <entry>Key</entry>
  72. <entry>Mandatory</entry>
  73. <entry>Description</entry>
  74. </row>
  75. </thead>
  76. <tbody>
  77. <row>
  78. <entry><codeph>name</codeph></entry>
  79. <entry>yes</entry>
  80. <entry>Plug-in name</entry>
  81. </row>
  82. <row>
  83. <entry><codeph>vers</codeph></entry>
  84. <entry>yes</entry>
  85. <entry>Plug-in version in <xref keyref="semver"/> format</entry>
  86. </row>
  87. <row>
  88. <entry><codeph>deps</codeph></entry>
  89. <entry>yes</entry>
  90. <entry>Array of dependency entries. The only mandatory plug-in dependency is
  91. <codeph>org.dita.base</codeph>, which defines the supported DITA-OT platform.</entry>
  92. </row>
  93. <row>
  94. <entry><codeph>url</codeph></entry>
  95. <entry>yes</entry>
  96. <entry>Absolute URL to plug-in distribution file</entry>
  97. </row>
  98. <row>
  99. <entry><codeph>cksum</codeph></entry>
  100. <entry>no</entry>
  101. <entry>SHA-256 hash of the plug-in distribution file</entry>
  102. </row>
  103. <row>
  104. <entry><codeph>description</codeph></entry>
  105. <entry>no</entry>
  106. <entry>Description of the plug-in</entry>
  107. </row>
  108. <row>
  109. <entry><codeph>keywords</codeph></entry>
  110. <entry>no</entry>
  111. <entry>Array of keywords</entry>
  112. </row>
  113. <row>
  114. <entry><codeph>homepage</codeph></entry>
  115. <entry>no</entry>
  116. <entry>Plug-in homepage URL</entry>
  117. </row>
  118. <row>
  119. <entry><codeph>license</codeph></entry>
  120. <entry>no</entry>
  121. <entry>License in <xref href="https://spdx.org/licenses/" format="html" scope="external">SPDX</xref>
  122. format</entry>
  123. </row>
  124. </tbody>
  125. </tgroup>
  126. </table>
  127. <note type="tip">To calculate the SHA-256 checksum for the <codeph>cksum</codeph> key, use <codeph>shasum -a 256
  128. <varname>&lt;plugin-file&gt;</varname></codeph> on macOS or Linux. With Windows PowerShell, use
  129. <codeph><xref
  130. href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash?view=powershell-6"
  131. format="html" scope="external">Get-FileHash</xref> <varname>&lt;plugin-file&gt;</varname> |
  132. Format-List</codeph>.
  133. <indexterm>macOS<indexterm>plug-in registry checksum</indexterm></indexterm>
  134. <indexterm>Linux<indexterm>plug-in registry checksum</indexterm></indexterm>
  135. <indexterm>Windows<indexterm>plug-in registry checksum</indexterm></indexterm>
  136. </note>
  137. <table outputclass="table-hover" frame="none" colsep="0" rowsep="1">
  138. <title>Structure for dependency entries</title>
  139. <tgroup cols="3">
  140. <colspec colwidth="1*"/>
  141. <colspec colwidth="1*"/>
  142. <colspec colwidth="3*"/>
  143. <thead>
  144. <row>
  145. <entry>Key</entry>
  146. <entry>Mandatory</entry>
  147. <entry>Description</entry>
  148. </row>
  149. </thead>
  150. <tbody>
  151. <row>
  152. <entry><codeph>name</codeph></entry>
  153. <entry>yes</entry>
  154. <entry>Plug-in name</entry>
  155. </row>
  156. <row>
  157. <entry><codeph>req</codeph></entry>
  158. <entry>yes</entry>
  159. <entry>Required plug-in version in <xref keyref="semver"/> format that may contain <xref
  160. href="https://docs.npmjs.com/misc/semver#ranges" format="html" scope="external">ranges</xref>.</entry>
  161. </row>
  162. </tbody>
  163. </tgroup>
  164. </table>
  165. <note>Version numbers in the <codeph>vers</codeph> and <codeph>req</codeph> keys use the three-digit format
  166. specified by <xref keyref="semver"/>. An initial development release of a plug-in might start at version 0.1.0,
  167. and an initial production release at 1.0.0. If your plug-in requires DITA-OT 3.1 or later, set the
  168. <codeph>req</codeph> key to <codeph>&gt;=3.1.0</codeph>. Using the greater-than sign allows your plug-in to
  169. work with compatible maintenance releases, such as 3.1.3. If the requirement is set to <codeph>=3.1.0</codeph>,
  170. the registry will only offer it for installation on that exact version.</note>
  171. </section>
  172. <section id="example-1">
  173. <title>Sample plug-in entry file</title>
  174. <div outputclass="div-index">
  175. <indexterm>DocBook</indexterm>
  176. </div>
  177. <p>The example below shows an entry for the <codeph>DocBook</codeph> plug-in. The complete file is available in
  178. the registry as <xref href="https://github.com/dita-ot/registry/blob/master/org.dita.docbook.json" format="json"
  179. scope="external">org.dita.docbook.json</xref>.</p>
  180. <codeblock outputclass="language-json" xml:space="preserve">[
  181. {
  182. "name": "org.dita.docbook",
  183. "description": "Convert DITA to DocBook.",
  184. "keywords": ["DocBook"],
  185. "homepage": "https://github.com/dita-ot/org.dita.docbook/",
  186. "vers": "2.3.0",
  187. "license": "Apache-2.0",
  188. "deps": [
  189. {
  190. "name": "org.dita.base",
  191. "req": ">=2.3.0"
  192. }
  193. ],
  194. "url": "https://github.com/dita-ot/org.dita.docbook/archive/2.3.zip",
  195. "cksum": "eaf06b0dca8d942bd4152615e39ee8cfb73a624b96d70e10ab269ed6f8a13e21"
  196. }
  197. ]</codeblock>
  198. </section>
  199. <section id="multiple-versions">
  200. <title>Maintaining multiple plug-in versions</title>
  201. <p>When you have multiple versions of a plug-in, include an entry for each version, separated by a comma:</p>
  202. <codeblock outputclass="language-json">[
  203. {
  204. "name": "org.example.myplugin",
  205. "vers": "1.0.1",
  206. }<b>,</b>
  207. {
  208. "name": "org.example.myplugin",
  209. "vers": "2.1.0",
  210. }
  211. ]</codeblock>
  212. <note type="tip">To publish a new version of your plug-in to the registry, add a new entry to the array in the
  213. existing plug-in entry file rather than overwriting an existing entry. This allows users to install the previous
  214. version of the plug-in if they are using an older version of DITA-OT.</note>
  215. </section>
  216. <section id="adding-custom-registries">
  217. <title>Adding custom registries</title>
  218. <p>In addition to the main plug-in registry at <xref keyref="site-plugin-registry"/>, you can create a registry of
  219. your own to store the custom plug-ins for your company or organization.</p>
  220. <p>A registry is just a directory that contains JSON files like the one above; each JSON file represents one entry
  221. in the registry. To add a custom registry location, edit the
  222. <filepath>config/configuration.properties</filepath> file in the DITA-OT installation directory and add the
  223. URL for your custom registry directory to the <codeph>registry</codeph> key value, separating each entry with a
  224. space.</p>
  225. <note type="tip">Custom registry entries are a simple way to test your own plug-in entry file before submitting to
  226. a common registry.</note>
  227. </section>
  228. <section id="testing-custom-registry"><title>Testing with a custom registry</title>
  229. <p>To test your plug-in entry with a custom registry:</p>
  230. <ol>
  231. <li>Fork the plug-in registry, which creates a new repository under your GitHub username — for example,
  232. <codeph>https://github.com/USERNAME/registry.git</codeph>.</li>
  233. <li>Create a new branch for your plug-in entry, and add the JSON file to the branch — for example, create
  234. <filepath>org.example.newPlugin.json</filepath> in the branch <codeph>addPlugin</codeph>.</li>
  235. <li>As long as your repository is accessible, that branch now represents a working “custom registry” that can be
  236. added to the <filepath>config/configuration.properties</filepath> file. Edit the <codeph>registry</codeph> key
  237. and add the raw GitHub URL for the branch that contains the JSON file. With the example username and branch
  238. name above, you can add your registry
  239. with:<codeblock outputclass="language-properties">registry=https://raw.githubusercontent.com/USERNAME/registry/addPlugin/ http://plugins.dita-ot.org/</codeblock></li>
  240. <li>You can now test the plug-in installation with:
  241. <codeblock><cmdname>dita</cmdname> <parmname>--install</parmname>=org.example.newPlugin</codeblock></li>
  242. <li>Once you’ve confirmed that the entry works, you can submit a pull request to have your entry added to the
  243. common registry.</li>
  244. </ol>
  245. </section>
  246. </body>
  247. </topic>