plugins-registry.dita 13 KB

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