|
NAMEumlclass.pl - Utility to generate UML class diagrams from Perl source or runtimeSYNOPSIS# generate a PNG file for the Foo module: $ umlclass.pl -M Foo -o foo.png -p "^Foo::" # generate an SVG image file which is vectorized and super clear: $ umlclass.pl --without-inherited-methods -o foo.svg -r lib/ # generate the dot source file: $ umlclass.pl -M Foo -o foo.dot $ umlclass.pl -o bar.gif -p "Bar::|Baz::" lib/Bar.pm lib/*/*.pm $ umlclass.pl -o blah.png -p Blah -r ./blib $ umlclass.pl --without-inherited-methods -o blah.png -r lib DESCRIPTIONThis is a simple command-line frontend for the UML::Class::Simple module.I'll illustrate the usage of this tool via some real-world examples. Draw Stevan's Moose$ umlclass.pl -M Moose -o samples/moose_small.png -p "^(Class::MOP|Moose::)" -s 4x8 This command will generate a simple class diagram in PNG format for the Moose module with classes having names matching the regex "^(Class::MOP|Moose::)". The image's width is 4 inches while its height is 8 inches. We need the -M option here since "umlclass.pl" needs to preload Moose into the memory so as to inspect it at runtime. The graphical output is given below: (See also <http://perlcabal.org/agent/images/moose_small.png>.) Yes, the image above looks very fuzzy since the whole stuff is huge. If you strip the -s option, then the resulting image will enlarge automatically: $ umlclass.pl -M Moose -o samples/moose_big.png -p "^(Class::MOP|Moose::)" The image obtained is really really large, I won't show it here, but you can browse it in your favorite picture browser from <http://perlcabal.org/agent/images/moose_big.png>. Before trying out these commands yourself, please make sure that you have Moose already installed. (It's also on CPAN, btw.) Perl libraries that use MoosePerl classes that inherit from Moose will have tons of "meta methods" like "before", "after", "has", and "meta", which are not very interesting while plotting the class diagram. So it's common practice to specify the "--without-inherited-methods" option like this:$ umlclass.pl --without-inherited-methods -o uml.png -r lib If you also add "--moose-roles", extra edges will appear in the graph, in an alternate color, representing the relationships between roles and their consumers. Draw Alias's PPI$ umlclass.pl -M PPI -o samples/ppi_small.png -p "^PPI::" -s 10x10 (See also <http://perlcabal.org/agent/images/ppi_small.png>.) Or the full-size version: $ umlclass.pl -M PPI -o samples/ppi_big.png -p "^PPI::" (See <http://perlcabal.org/agent/images/ppi_big.png>.) BTW, PPI is a prerequisite of this module. Draw FAST.pm from UML::Class::Simple's Test Suite$ umlclass.pl -M FAST -o samples/fast.png -s 5x10 -r t/FAST/lib This is an example of drawing classes contained in Perl source files. Draw Modules of Your OwnSuppose that you're a CPAN author too and want to produce a class diagram for all the classes contained in your lib/ directory. The following command can do all the hard work for you:$ umlclass.pl -o mylib.png -r lib or just plot the packages in the specified .pm files: $ umlclass.pl -o a.png lib/foo.pm lib/bar/baz.pm or even specify a pattern (in perl regex) to filter out the packages you want to draw: $ umlclass.pl -o a.png -p "^Foo::" lib/foo.pm Quite handy, isn't it? ;-) IMPORTANT ISSUESNever feed plain module names to umlclass.pl, for intance,$ umlclass.pl Scalar::Defer # DO NOT DO THIS! will lead you to the following error message: error: input file Scalar::Defer not found. Use "-M" and "-p" options to achieve your goals: $ umlclass.pl -M Scalar::Defer -p "Scalar::Defer" In this example, I must warn you that you may miss the packages which belong to Scalar::Defer but don't have "Scalar::Defer" in their names. I'm sorry for that. umlclass.pl is not that smart. The safest ways to do this are
It's worth mentioning that when .pl or .pm files are passing as the command line arguments, only the classes defined in these files will be drawn. This is a feature. :) For .pm files on your disk, simply pass them as the command line arguments. For instance: $ umlclass.pl -o bar.gif lib/Bar.pm lib/*/*.pm or tell umlclass.pl to iterate through the directories for you: $ umlclass.pl -o blah.png -r ./lib OPTIONS
TODO
AUTHORSYichun Zhang <agentzh@gmail.com>, Maxim Zenin <max@foggy.ru>COPYRIGHTCopyright 2006-2017 by Yichun Zhang. All rights reserved.This library is free software; you can redistribute it and/or modify it under the same terms as perl itself. SEE ALSOUML::Class::Simple.
Visit the GSP FreeBSD Man Page Interface. |