14

How can I generate a UML sequence diagram from a file containing a textual representation of my process, with command-line tools in Linux?

user336639
  • 228
  • 1
  • 2
  • 7

7 Answers7

17

Although PlantUML is listed in the accepted answer (among many other tools) it merits more attention.

In addition to being easily wrapped into a command line tool, PlantUML also has

  1. excellent documentation (check out the docs for sequence diagrams)
  2. simple and powerful syntax (may compare favorably with UMLGraph)
  3. styleable output
  4. extensive tool integration (Emacs, Sphinx)

However PlantUML comes as a java archive so the following setup may be required:

  1. java
  2. graphviz (not required for sequence diagrams)
  3. a bash wrapper

java and graphviz are available as packages for the major linux distros. PlantUML itself is available for Fedora and Ubuntu.

If your distribution does not provide a package, download a jar file from the main site and wrap as a bash script.

A bash wrapper (as follows) can be stored in a file named plantuml on your path i.e. one of the directories listed by echo $PATH. Don't forget to make it executable with chmod u+x plantuml.

#!/bin/bash
# from the vim syntax plugin README at aklt/plantuml-syntax on github
java -jar $HOME/path/to/plantuml.jar -tsvg $@

Then run plantuml apple.uml berry.uml and plantuml will create apple.svg berry.svg.

wolfmanx
  • 481
  • 5
  • 12
Salticus
  • 403
  • 4
  • 9
6

There are many (many=more than 10) tools for this.
See a complete list.

Jordi Cabot
  • 8,058
  • 2
  • 33
  • 39
2

Not sure if it's what you want, but UMLGraph can generate sequence diagrams using graphviz and ghostscript...

jcayzac
  • 1,441
  • 1
  • 13
  • 26
  • 1
    Ghostscript isn't needed. GraphViz can directly generate PNG, SVG, and many other file types. – Diomidis Spinellis Jul 08 '10 at 14:09
  • @Diomidis: re-reading my comment, I realize I got several things mixed up: - GraphViz (alone) is used to generate class diagrams - the GNU plotutils (alone) are used to generate sequence diagrams. In some script I wrote a long time ago, I was using ghostscript to render the diagram at a high resolution. Then it was fed to ImageMagick to make the background transparent. See http://blog.julien.cayzac.name/2004/11/drawing-uml-sequence-diagrams-with-gnu.html – jcayzac Aug 04 '10 at 01:46
2

If your text representation is closely similar to yuml, you might be able to use it to produce images, e.g.

Simple Association

[Customer]->[Billing Address]
<img src="http://yuml.me/diagram/scruffy/class/[Customer]->[Billing Address]"/>
Image of sample UML relationship

Community
  • 1
  • 1
Bert F
  • 85,407
  • 12
  • 106
  • 123
2

http://umlet.com/ is another solution

Florian Diesch
  • 1,025
  • 10
  • 16
2

Put the following source into .html file and open it in a browser:

<html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script>
            $(document).ready(function () {
                $('textarea').each(function () {
                    $(this).hide();
                    var source = $(this).html();
                    $('body').append('<img src="http://yuml.me/diagram/scruffy/class/'
                        + source + '" />');
                });
            });
        </script>
    </head>
    <body>
        <textarea>
            [note: You can stick notes on diagrams too!{bg:cornsilk}],
            [Customer]<>1-orders 0..*>[Order],
            [Order]++*-*>[LineItem],
            [Order]-1>[DeliveryMethod],
            [Order]*-*>[Product],
            [Category]<->[Product],
            [DeliveryMethod]^[National],
            [DeliveryMethod]^[International]
        </textarea>
    </body>
</html>

You should be able to see the sample diagram corresponding to the source within the textarea tag. Correct the source according to the yuml samples to draw your own diagram.

nab
  • 4,751
  • 4
  • 31
  • 42
-1

Use a script to replace:

  • One space with multiple spaces
  • Commas with column characters, such as |
  • Newline characters with carriage returns plus space indentation
  • Dashes with multiple dashes
  • Greater than and less than characters with column span characters

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265