Readme.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. ================================================
  2. PlantUML plugin for Pelican rst and md documents
  3. ================================================
  4. This plugin allows you to define UML diagrams directly into rst or md documents using the great
  5. PlantUML_ tool.
  6. It gets the content of ``uml`` directive, passes it to the external
  7. program PlantUML_ and then links the generated image to the document.
  8. .. contents::
  9. Installation
  10. ============
  11. You need to install PlantUML_ (see the site for details) and Graphviz_ 2.26.3 or later.
  12. The plugin expects a program ``plantuml`` in the classpath. If not installed by your package
  13. manager, you can create a shell script and place it somewhere in the classpath. For example,
  14. save te following into ``/usr/local/bin/plantuml`` (supposing PlantUML_ installed into
  15. ``/opt/plantuml``):
  16. .. code-block:: bash
  17. #!/bin/bash
  18. java -jar /opt/plantuml/plantuml.jar ${@}
  19. For Gentoo_ there is an ebuild at http://gpo.zugaina.org/dev-util/plantuml/RDep: you can download
  20. the ebuild and the ``files`` subfolder or you can add the ``zugaina`` repository with _layman
  21. (reccomended).
  22. Usage
  23. =====
  24. Add ``plantuml`` to plugin list in ``pelicanconf.py``. For example:
  25. .. code-block:: ptyhon
  26. PLUGINS = [ "sitemap", "plantuml" ]
  27. One loaded the plugin register also the Pyhton-Markdown_ extension.
  28. RST usage
  29. ---------
  30. Use the ``uml`` directive to start UML diagram description. It is not necessary to enclose
  31. diagram body between ``@startuml`` and ``@enduml`` directives: they are added automatically
  32. before calling ``plantuml``.
  33. In addition to ``class`` and
  34. ``alt`` options common to all images, you can use the ``format`` option to select what kind
  35. of image must be produced. At the moment only ``png`` and ``svg`` are supported; the default
  36. is ``png``.
  37. Please note that the ``format`` option in not recognized by the ``plantuml`` extension of
  38. ``rst2pdf`` utility (call it with ``-e plantuml.py``) so if you use it you can get errors from
  39. that program.
  40. MD usage
  41. --------
  42. For use with the Pyhton-Markdown_ syntax, the UML block must be enclose with ``::uml::``:
  43. .. code-block:: markdown
  44. ::uml:: [format=...] [classes=...] [alt=...]
  45. PlantUML script
  46. ::end-uml::
  47. Please keep a blank line before ``::uml::`` and after ``::end-uml::`` to be sure that the UML code will be correctly
  48. recognized.
  49. See Examples_ for more details.
  50. With MD syntax options must be specified in the same line as the opening ``:uml::``, with the
  51. order ``format``, ``classes`` anmd ``alt``. The general syntax for option is
  52. .. code-block:: text
  53. option="value"
  54. Option can be enclosed with single or double quotes, as you like.
  55. Options defaults are the same as for the rst plugin.
  56. Debugging
  57. ---------
  58. The plugin can produce debugging informations to help to locate errors. To enable debugging
  59. execute ``pelican`` in debug mode:
  60. .. code-block:: console
  61. make DEBUG=1 html
  62. Examples
  63. ========
  64. Sequence diagram (from PlantUML_ site):
  65. .. code-block:: rst
  66. .. uml::
  67. :alt: Sample sequence diagram
  68. participant User
  69. User -> A: DoWork
  70. activate A #FFBBBB
  71. A -> A: Internal call
  72. activate A #DarkSalmon
  73. A -> B: << createRequest >>
  74. activate B
  75. B --> A: RequestCreated
  76. deactivate B
  77. deactivate A
  78. A -> User: Done
  79. deactivate A
  80. Output:
  81. .. image:: http://plantuml.sourceforge.net/imgp/sequence_022.png
  82. :alt: Sample sequence diagram
  83. Same diagram with Pyhton-Markdown_ syntax:
  84. .. code-block:: markdown
  85. ::uml:: format="png" alt="Sample sequence diagram"
  86. participant User
  87. User -> A: DoWork
  88. activate A #FFBBBB
  89. A -> A: Internal call
  90. activate A #DarkSalmon
  91. A -> B: << createRequest >>
  92. activate B
  93. B --> A: RequestCreated
  94. deactivate B
  95. deactivate A
  96. A -> User: Done
  97. deactivate A
  98. ::end-uml::
  99. Another example from PlantUML_ site (activity diagram):
  100. .. code-block:: rst
  101. .. uml::
  102. start
  103. :ClickServlet.handleRequest();
  104. :new page;
  105. if (Page.onSecurityCheck) then (true)
  106. :Page.onInit();
  107. if (isForward?) then (no)
  108. :Process controls;
  109. if (continue processing?) then (no)
  110. stop
  111. endif
  112. if (isPost?) then (yes)
  113. :Page.onPost();
  114. else (no)
  115. :Page.onGet();
  116. endif
  117. :Page.onRender();
  118. endif
  119. else (false)
  120. endif
  121. if (do redirect?) then (yes)
  122. :redirect process;
  123. else
  124. if (do forward?) then (yes)
  125. :Forward request;
  126. else (no)
  127. :Render page template;
  128. endif
  129. endif
  130. stop
  131. Generated image:
  132. .. image:: http://plantuml.sourceforge.net/imgp/activity2_009.png
  133. :alt: Sample activity diagram
  134. .. _PlantUML: http://plantuml.sourceforge.net
  135. .. _Sabayon: http://www.sabayon.org
  136. .. _Gentoo: http://www.gentoo.org
  137. .. _layman: http://wiki.gentoo.org/wiki/Layman
  138. .. _Graphviz: http://www.graphviz.org
  139. .. _Pyhton-Markdown: http://pythonhosted.org/Markdown