Git Product home page Git Product logo

sequenceplot's Introduction

SequencePlot - A Python module for generating UML sequence diagrams

Introduction

UML sequence diagrams are useful for describing communication between interacting objects. That said, they are cumbersome to draw and maintain using GUI tools. An alternative approach is to code the interactions which can then be generated into a diagram.

SequencePlot is a Python module for using code to generate a UML sequence diagram. The sequence diagram can be rendered in a svg, ps, or png format.

SequencePlot is built on top of the sequence.pic macros from UMLGraph which in turn use the GNU Plotutils pic2plot utility. SequencePlot treats the pic macros defined in sequence.pic as drawing primitives that are more easily controlled via the object oriented abstractions offered by Python.

Requirements

  • GNU Plotutils
  • Python 2.6+

Release Notes (v0.4)

This code is stable enough to draw sequence diagrams. Come in, the water is fine.

TODO

  • Stable documentation of classes
  • Better error handling
  • Package the module using standard Python distribution conventions.
  • More code examples

Quick Start

  • Make sure the directory holding the module folder sequenceplot is included in your PYTHONPATH environment variable.

  • Enter the following Python code into the file sd_authenticate.py.

      from sequenceplot import SequenceObject, SequenceDiagram
    
      client = SequenceObject('c: client')
      server = SequenceObject('s: server')
    
      diagram = SequenceDiagram([client, server])
      diagram.setParam('objectSpacing', 1.75)
    
      diagram.beginFrame(client, 'Login')
      client.callMethod(server, 'login(username, password)', response='sessionID, userInfo')
      diagram.endFrame(server)
    
      diagram.svg('sd_authenticate')
    
  • Execute the following line:

      $ python sd_authenticate.py
    

The following files will be generated:

  • sd_authenticate.svg - UML sequence diagram in SVG format
  • sd_authenticate.pic - UML sequence diagram in pic format

Click to view the SVG output.

Documentation

Creating a UML sequence diagram with SequencePlot entails the following steps:

  1. Import required objects from sequenceplot module.
  2. Instantiate objects with base type SequenceObject.
  3. Instantiate diagram with type SequenceDiagram.
  4. Configure diagram object.
    • Configure parameters using diagram.setParam(key, value)
  5. Define interactions between objects. Common messages sent between objects are:
    • Call method on another object. Example: client.callMethod(target, 'getUserInfo()', 'userInfo')
    • Create instance of another object. Example: server.createInstance(hashTable, 'hash table')
    • Destroy instance of another object. Example: server.destroyInstance(hashTable)
  6. Generate the sequence diagram.
    • Generate SVG file. Example: diagram.svg('diagram')
    • Generate PS file. Example: diagram.ps('diagram')
    • Generate PNG file. Example: diagram.png('diagram')
    • Emit pic commands to stdout. Example: diagram.run()

Examples

It is strongly recommended to read the Python source files in the folder examples. They will provide a better understanding of the expressive capabilities of this package.

Pydoc

To generate pydoc HTML, run the following command in the top level directory of this project:

$ make docs

Alternately, to view documentation online:

$ pydoc sequenceplot
$ pydoc sequenceplot.SequenceDiagram
$ pydoc sequenceplot.SequenceObject

UMLGraph Documentation

To debug the pic files generated by SequencePlot, please refer to the UMLGraph Sequence Diagram documentation.

License

Copyright 2012 Yummy Melon Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Attributions

sequence.pic

Pic macros for drawing UML sequence diagrams
(C) Copyright 2004-2005 Diomidis Spinellis.
Permission to use, copy, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

sequenceplot's People

Contributors

kickingvegas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ywptr

sequenceplot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.