I'm working on modules which draw UML sequence
diagrams.  My suggested namespace is UML::Sequence.

Currently the modules sequence Perl programs using
dprofpp -T output and Java programs using my own Java
tool.  In both cases the diagrams show only the
classes and messages you care about.  The final output
is in svg.  These diagrams reflect what actually
happened when a program ran.

They can also build a diagram from a simple outline. 
This is nice for design diagrams.

Please send any comments or questions to me at
[EMAIL PROTECTED]  Namespace comments are
particularly welcome.  Also, is it inapproapriate to
include the Java sequencing tool on CPAN (it's written
in Java)?

Thanks,

Phil Crow

Here's an outline of the rest of this RFC:
    Current steps for sequencing a Perl program
    The code in the genericseq script
    The POD from UML::PerlSeq
    The svg output for a simple demo program

Current steps for sequencing a Perl program:

1. Make a flat file listing methods you want included
in the diagram.
2. Run the genericseq:

    genericseq UML::PerlSeq method_file program
[args_for_program...] > prog.xml

3. Convert the xml sequence into svg:

    seqtosvg < prog.xml > prog.svg

The code in the genericseq script shows a typical
usage of the underlying modules:

use UML::Sequence;

my $usage = "usage: $0 outline_style
[outline_args...]\n";

my $style       = shift;
my $outline;
my $methods;
my $parse_method;

{
    no      strict;
    require "$style.pm";

    $outline      = $style->grab_outline_text(@ARGV);
    $methods      = $style->grab_methods($outline);
    $parse_method = $style->can(parse_signature);
}

my $tree = UML::Sequence->new($methods, $outline,
$parse_method);

print $tree->build_xml_sequence();

The outline_style classes perform language specific
tasks and conform to
a common API.
The POD from UML::PerlSeq:

NAME
    UML::PerlSeq - for use with genericseq script,
works on Perl programs

SYNOPSIS
        genericseq UML::PerlSeq methods_file
perl_program [args...] > out.xml
        seqtosvg out.xml > out.svg

    OR

        genericseq UML::PerlSeq methods_file prog
[args...] | seqtosvg > out.svg

DESCRIPTION
    This file must be used by a script. On demand it
will form an outline by running the supplied program
with -d:DProf and interpreting the output with
dprofpp. Both of these tools ship with Perl. This has
been developed on Cygwin under Windows 2000 and tested
on Red Hat Linux 7.1.

    The methods file should list methods you WANT to
hear about. If it isn't in the list, it will not
appear in the picture. The format of the file is like
this:

        DiePair::new
        Die::new
        DiePair::roll
        Die::roll
        DiePair::total
        DiePair::doubles
        DiePair::to_string

    Order is not important.

METHODS

grab_outline_text
    Call this method first. Call it through the class
(UML::PerlSeq->grab_outline_text) passing it the
methods_file, the program to run, and any args for
that program. Returns an outline (suitable for
printing or passing on to SeqOutline).

grab_methods
    Call this only after you have called grab_outline.
Call it through the class: UML::PerlSeq->grab_methods.
Arguments are ignored. Returns a reference to an array
listing the methods of interest.

parse_signature
    Pass a reference to this method to the
UML::Sequence constructor. It must accept a method
signature and return the class name (in scalar
context) or the class and method names in that order
(in list context).

The svg output for a simple demo program:

<?xml version="1.0"?>
  <svg xmlns="http://www.w3.org/2000/svg"; height="460"
width="424">
    <defs>
      <style type="text/css">
              rect, line, path { stroke-width: 2;
stroke: black }
              text { font-weight: bold }
      <marker orient="auto" refY="2.5" refX="4"
markerHeight="5"
              markerWidth="4" id="mArrow">
        <path style="fill: black; stroke: none" d="M 0
0 4 2 0 5"/>
      </marker>
      </style>
    </defs>
    <text x="5" y="15">
        roller DiePair.pm demo
    </text>
<text y='40' x='30'>main</text>
  <rect style='fill: none' height='20' width='125'
y='25' x='22' />
  <line style='stroke-dasharray: 4,4; ' fill='none'
stroke='black' x1='92' y1='55' x2='92' y2='455' />
    <rect style='fill: white' height='380' width='15'
y='55' x='84'/>

<text y='40' x='158'>DiePair</text>
  <rect style='fill: none' height='20' width='125'
y='25' x='150' />
  <line style='stroke-dasharray: 4,4; ' fill='none'
stroke='black' x1='220' y1='95' x2='220' y2='455' />
    <rect style='fill: white' height='100' width='15'
y='95' x='212'/>
    <rect style='fill: white' height='100' width='15'
y='215' x='212'/>
    <rect style='fill: white' height='20' width='15'
y='335' x='212'/>
    <rect style='fill: white' height='20' width='15'
y='375' x='212'/>
    <rect style='fill: white' height='20' width='15'
y='415' x='212'/>

<text y='40' x='286'>Die</text>
  <rect style='fill: none' height='20' width='125'
y='25' x='278' />
  <line style='stroke-dasharray: 4,4; ' fill='none'
stroke='black' x1='348' y1='135' x2='348' y2='455' />
    <rect style='fill: white' height='20' width='15'
y='135' x='340'/>
    <rect style='fill: white' height='20' width='15'
y='175' x='340'/>
    <rect style='fill: white' height='20' width='15'
y='255' x='340'/>
    <rect style='fill: white' height='20' width='15'
y='295' x='340'/>

<line x1='100' y1='95' x2='213' y2='95'
style='marker-end: url(#mArrow);' />
<text x='103' y='91'>new</text>
<line x1='228' y1='135' x2='341' y2='135'
style='marker-end: url(#mArrow);' />
<text x='231' y='131'>new</text>
<line x1='228' y1='175' x2='341' y2='175'
style='marker-end: url(#mArrow);' />
<text x='231' y='171'>new</text>
<line x1='100' y1='215' x2='213' y2='215'
style='marker-end: url(#mArrow);' />
<text x='103' y='211'>roll</text>
<line x1='228' y1='255' x2='341' y2='255'
style='marker-end: url(#mArrow);' />
<text x='231' y='251'>roll</text>
<line x1='228' y1='295' x2='341' y2='295'
style='marker-end: url(#mArrow);' />
<text x='231' y='291'>roll</text>
<line x1='100' y1='335' x2='213' y2='335'
style='marker-end: url(#mArrow);' />
<text x='103' y='331'>total</text>
<line x1='100' y1='375' x2='213' y2='375'
style='marker-end: url(#mArrow);' />
<text x='103' y='371'>doubles</text>
<line x1='100' y1='415' x2='213' y2='415'
style='marker-end: url(#mArrow);' />
<text x='103' y='411'>to_string</text>
</svg>

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Reply via email to