<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Pyreverse : UML Diagrams for Python (Logilab.org) RSS Feed</title>
    <description></description>
    <link>http://www.logilab.org/blogentry/6883</link>
<item>
<guid isPermaLink="true">http://www.logilab.org/blogentry/6883</guid>
  <title>Pyreverse : UML Diagrams for Python</title>
  <link>http://www.logilab.org/blogentry/6883</link>
  <description>&lt;p&gt;Pyreverse analyses Python code and extracts UML class diagrams
and package depenndencies. Since september 2008 it has been integrated with &lt;a class=&quot;reference&quot; href=&quot;http://www.logilab.org/project/pylint&quot;&gt;Pylint&lt;/a&gt; (0.15).&lt;/p&gt;
&lt;div class=&quot;section&quot; id=&quot;introduction&quot;&gt;
&lt;h3&gt;&lt;a&gt;Introduction&lt;/a&gt;&lt;/h3&gt;
&lt;dl class=&quot;docutils&quot;&gt;
&lt;dt&gt;Pyreverse builds a diagram representation of the source code with:&lt;/dt&gt;
&lt;dd&gt;&lt;ul class=&quot;first last simple&quot;&gt;
&lt;li&gt;class attributes, if possible with their type&lt;/li&gt;
&lt;li&gt;class methods&lt;/li&gt;
&lt;li&gt;inheritance links between classes&lt;/li&gt;
&lt;li&gt;association links between classes&lt;/li&gt;
&lt;li&gt;representation of Exceptions and Interfaces&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;generation-of-uml-diagrams-with-pyreverse&quot;&gt;
&lt;h3&gt;&lt;a&gt;Generation of UML diagrams with Pyreverse&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The command &lt;strong&gt;pyreverse&lt;/strong&gt; generates the diagrams in all formats that &lt;em&gt;graphviz/dot&lt;/em&gt;
knows, or in &lt;em&gt;VCG&lt;/em&gt; :&lt;/p&gt;
&lt;p&gt;The following command shows what &lt;em&gt;dot&lt;/em&gt; knows:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
$ dot -Txxx
Format: &amp;quot;xxx&amp;quot; not recognized. Use one of: canon cmap cmapx cmapx_np dia dot
eps fig gd gd2 gif hpgl imap imap_np ismap jpe jpeg jpg mif mp pcl pdf pic
plain plain-ext png ps ps2 svg svgz tk vml vmlz vrml vtx wbmp xdot xlib
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;pyreverse&lt;/strong&gt; creates by default two diagrams:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
$ pyreverse -o png -p Pyreverse pylint/pyreverse/
[...]
creating diagram packages_Pyreverse.png
creating diagram classes_Pyreverse.png
&lt;/pre&gt;
&lt;div class=&quot;handout container&quot;&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;-o :  sets the output format&lt;/li&gt;
&lt;li&gt;-p name : yields the output files packages_name.png and classes_name.png&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;package-diagram&quot;&gt;
&lt;h4&gt;&lt;a&gt;Package Diagram&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;center container&quot;&gt;
&lt;img alt=&quot;[image : packages_Pyreverse.png]&quot; src=&quot;http://www.logilab.org/image/6886?vid=download&quot; /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;class-diagram&quot;&gt;
&lt;h4&gt;&lt;a&gt;Class Diagram&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;center container&quot;&gt;
&lt;a class=&quot;reference image-reference&quot; href=&quot;http://www.logilab.org/image/6887?vid=download&quot;&gt;&lt;img alt=&quot;[image : classes_Pyreverse.png]&quot; src=&quot;http://www.logilab.org/image/6887?vid=download&amp;amp;small=true&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a class=&quot;reference&quot; href=&quot;http://www.logilab.org/image/6887?vid=download&quot;&gt;class diagram full size image&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;options&quot;&gt;
&lt;h3&gt;&lt;a&gt;Options&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;One can modify the output with following options:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
-a N, -A    depth of research for ancestors
-s N, -S    depth of research for associated classes
-A, -S      all ancestors, resp. all associated
-m[yn]      add or remove the module name
-f MOD      filter the attributes : PUB_ONLY/SPECIAL/OTHER/ALL
-k          show only the classes (no attributes and methods)
-b          show &#39;builtin&#39; objects
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;examples&quot;&gt;
&lt;h3&gt;&lt;a&gt;Examples:&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;section&quot; id=&quot;general-vue-on-a-module&quot;&gt;
&lt;h4&gt;&lt;a&gt;General Vue on a Module&lt;/a&gt;&lt;/h4&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
pyreverse -ASmy -k -o png pyreverse/main.py -p Main
&lt;/pre&gt;
&lt;div class=&quot;center container&quot;&gt;
&lt;a class=&quot;reference image-reference&quot; href=&quot;http://www.logilab.org/image/6885?vid=download&quot;&gt;&lt;img alt=&quot;[image : classes_Main.png, class diagram with all dependencies]&quot; src=&quot;http://www.logilab.org/image/6885?vid=download&amp;amp;small=true&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a class=&quot;reference&quot; href=&quot;http://www.logilab.org/image/6885?vid=download&quot;&gt;full size image&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;handout container&quot;&gt;
With these options you can have a quick vue of the dependencies without
being lost in endless lists of methods and attributes.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;detailed-vue-on-a-module&quot;&gt;
&lt;h4&gt;&lt;a&gt;Detailed Vue on a Module&lt;/a&gt;&lt;/h4&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
pyreverse -c PyreverseCommand -a1 -s1 -f ALL -o png  pyreverse/main.py
&lt;/pre&gt;
&lt;div class=&quot;center container&quot;&gt;
&lt;a class=&quot;reference image-reference&quot; href=&quot;http://www.logilab.org/image/6888?vid=download&quot;&gt;&lt;img alt=&quot;[image : PyreverseCommand.png, pyreverse.diagram.ClassDiagram class diagram with one dependency level]&quot; src=&quot;http://www.logilab.org/image/6888?vid=download&amp;amp;small=true&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a class=&quot;reference&quot; href=&quot;http://www.logilab.org/image/6888?vid=download&quot;&gt;module in full size image&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;handout container&quot;&gt;
Show all methods and attributes of the class (&lt;em&gt;-f ALL&lt;/em&gt;).
By default, the class diagram option &lt;em&gt;-c&lt;/em&gt; uses the options
&lt;em&gt;-A, -S, -my&lt;/em&gt;, but here we desactivate them
to get a reasonably small image.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;configuration-file&quot;&gt;
&lt;h3&gt;&lt;a&gt;Configuration File&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can put some options into the file &amp;quot;.pyreverserc&amp;quot; in your home directory.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Exemple&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
--filter-mode=PUB_ONLY --ignore doc --ignore test
&lt;/pre&gt;
&lt;div class=&quot;handout container&quot;&gt;
This will exclude documentation and test files in the &lt;em&gt;doc&lt;/em&gt; and &lt;em&gt;test&lt;/em&gt;
directories. Also, we will see only &amp;quot;public&amp;quot; methods.&lt;/div&gt;
&lt;/div&gt;
</description>
  <dc:date>2008-12-23T17:39-01:00</dc:date>
  <dc:creator>Emile Anclin</dc:creator>
</item>
  </channel>
</rss>