Home

Awesome

PlantUMLPharoGizmo

Pharo support for PlantUML.

Note: The GUI part of this project was initially done in Spec 2, which works best in Pharo 8. However, the baseline will load a GUI that works with Pharo 7.

Note 2: Many people have requested support for PlantUML without Moose, so I made a fork. I only tested it in Pharo 9 (PRs are welcome to make it work in Pharo 8):

Note 3: Have a look at https://github.com/kasperosterbye/PlantUMLBridge for a simpler version of the support in this tool.

Demo video of prototype

Loading (requires Moose)

Metacello new
  repository: 'github://fuhrmanator/PlantUMLPharoGizmo/src';
  baseline: 'PUGizmo';
  load.

Loading (without Moose, requires Pharo 9)

Metacello new
  repository: 'github://fuhrmanator/PlantUMLPharoGizmo:pharo9/src';
  baseline: 'PUGizmo';
  load.

Example

Class diagrams using a Moose Java model

One reason to get PlantUML working in Pharo was to use it with Moose, and there is now a Moose browser. Prerequisite: A generated MSE file for the sample project FactoryVariants was already loaded in Moose.

Screenshot of Moose browser

Here's the SVG of the diagram shown in the screenshot above, rendered from the PlantUML source that you can copy from the browser and render at PlantUML.com:

Class diagram

Programmatic usage

There's a utility method to generate PlantUML source for a Java model (see this example) in Moose.

| classes pUMLSource key serverUrl imageMorph w |
classes := (MooseModel root first allClasses reject:#isStub) 
  select: [:c | c mooseName beginsWith: 'headfirst::designpatterns::factory::pizzaaf'].
pUMLSource := PUGizmo plantUMLSourceForMooseClasses: classes.

key := pUMLSource plantDeflateAndEncode.
serverUrl := 'http://www.plantuml.com/plantuml/png/', key .
imageMorph := (ZnEasy getPng: serverUrl asUrl) asAlphaImageMorph .
imageMorph layout: #scaledAspect.
w := imageMorph openInWindow.
w center; fitInWorld.

Class diagram

Simple class diagram

plantUMLSource := '@startuml
skinparam style strictuml
skinparam backgroundcolor transparent
skinparam classbackgroundcolor Yellow/LightYellow
class Banana
note right #red: Ceci n''est pas\nune banane. 
@enduml'.

codePart := plantUMLSource plantDeflateAndEncode.

serverUrl := 'https://www.plantuml.com/plantuml/img/', codePart.
(ZnEasy getPng: serverUrl) asMorph openInWindow.

"Get the Source back from a URL"
recoveredSource := serverUrl plantUrlStringToPlantSourceString.

self assert: recoveredSource equals: plantUMLSource.

Class diagram

Mind map

plantUMLSource := '@startmindmap
* Debian
** Ubuntu
*** Linux Mint
*** Kubuntu
*** Lubuntu
*** KDE Neon
** LMDE
** SolydXK
** SteamOS
** Raspbian with a very long name
*** <s>Raspmbc</s> => OSMC
*** <s>Raspyfi</s> => Volumio
@endmindmap'.

codePart := plantUMLSource plantDeflateAndEncode.

serverUrl := 'https://www.plantuml.com/plantuml/img/', codePart.
(ZnEasy getPng: serverUrl) asMorph openInWindow.

Mind map