Commits

Anonymous committed d1af173

Updated Gouichi Iisaka's Graphviz filter to version 1.1.3.

Comments (0)

Files changed (2)

filters/graphviz/asciidoc-graphviz-sample.txt

 
 Author: Gouichi Iisaka
 
-Version: 1.0
+Version: 1.1.3
 
 == Introduction ==
 
-Graph visualization is a way of representing structural information
+The Graphviz(link:http://www.graphviz.org[]) is a way of representing structural information
 as diagrams of abstract graphs and networks.
 
+
+Automatic graph drawing has many important applications
+in software engineering, database and web design, networking,
+and in visual interfaces for many other domains.
+
+Graphviz take descriptions of graphs in a simple text language,
+And has many useful features for concrete diagrams,
+such as options for colors, fonts, tabular node layouts,
+line styles, hyperlinks, and custom shapes.
+
 AsciiDoc can external shell commands used to process Paragraph and 
 DelimitedBlock content by Filter.
 
+So now, AsciiDoc can draw graphs via graphviz filter.
 
-== Simple Example ==
+== Examples ==
 
+=== Simple ===
 --------------------------------------------------------------------
  ["graphviz", "sample1.png"]
  ---------------------------------------------------------------------
 digraph G { rankdir=LR; Graphviz->AsciiDoc->HTML}
 ---------------------------------------------------------------------
 
+=== Using options ===
 ---------------------------------------------------------------------
  ["graphviz", "sample2.png"]
  ---------------------------------------------------------------------
  ---------------------------------------------------------------------
 ---------------------------------------------------------------------
 
-["graphviz", "sample3.png"]
+["graphviz", "sample2.png"]
 ---------------------------------------------------------------------
 digraph automata_0 {
     size ="8.5, 11";
 } 
 ---------------------------------------------------------------------
 
+=== Using Layout ===
 
 --------------------------------------------------------------------
- ["graphviz", "sample4.png", "dot"]
+ ["graphviz", "sample3.png", "dot"]
  ---------------------------------------------------------------------
  digraph finite_state_machine {
     rankdir=LR;
  ---------------------------------------------------------------------
 --------------------------------------------------------------------
 
-.Example for `dot':
-["graphviz", "sample4.png", "dot"]
+["graphviz", "sample3.png", "dot"]
 ---------------------------------------------------------------------
 digraph finite_state_machine {
     rankdir=LR;
 
 == Layout ==
 
-layout for graphviz as follows.
+Layout for graphviz as follows.  The default is `dot'.
 
- * dot::    filter for drawing directed graphs
- * neato::  filter for drawing undirected graphs
- * twopi::  filter for radial layouts of graphs
- * circo::  filter for circular layout of graphs
- * fdp::    filter for drawing undirected graphs
+    *dot;;
+    'dot' draws directed graphs.
+    It works well on DAGs and other graphs that can be drawn as hierarchies.
+    It  reads attributed graph files and writes drawings.
 
-default is `dot'.
+    *neato;;
+    'neato' draws  undirected graphs using ‘‘spring'' models (see Kamada and
+    Kawai, Information Processing Letters 31:1, April 1989).
+    Input  files must be formatted in the dot attributed graph language.
 
+    *twopi;;
+    'twopi'  draws  graphs  using a radial layout (see G. Wills, Symposium on
+    Graph Drawing GD'97, September, 1997). 
+    Basically, one node  is  chosen as the center and put at the origin.
+    The remaining nodes are placed on a sequence of concentric circles
+    centered about the origin, each a fixed radial distance from
+    the previous circle.
+
+    *circro;;
+    'circo' draws graphs using a circular layout (see Six and Tollis, GD  '99
+    and  ALENEX  '99, and Kaufmann and Wiese, GD '02.)
+    The tool identifies biconnected components and draws the nodes
+    of the component on  a  circle.
+    The block‐cutpoint tree is then laid out using a recursive radial
+    algorithm.
+    Edge crossings within a circle are minimized by  placing  as
+    many  edges  on  the circle's perimeter as possible.
+    In particular, if the component is outerplanar,
+    the component will have a planar  layout.
+
+    *fdp;;
+     'fdp'  draws undirected graphs using a ‘‘spring'' model.
+     It relies on a force‐directed approach in the spirit of Fruchterman
+     and Reingold 
+     (cf.  Software‐Practice & Experience 21(11), 1991, pp. 1129‐1164).

filters/graphviz/graphviz2png.py

 #!/usr/bin/env python
+
 import os, sys
 from optparse import *
 
 __AUTHOR__ = "Gouichi Iisaka <iisaka51@gmail.com>"
-__VERSION__ = '1.1'
+__VERSION__ = '1.1.3'
 
 class EApp(Exception):
     '''Application specific exception.'''
     pass
 
-class Struct:
-    '''variable contenor as C `struct'.'''
-    pass
-
 class Application():
     '''
 NAME
 
 
 OPTIONS
-    -o OUTFILE
+    -o OUTFILE, --outfile=OUTFILE
         The file name of the output file. If not specified the output file is
         named like INFILE but with a .png file name extension.
 
-    -v
+    -L LAYOUT, --layout=LAYOUT
+        Graphviz layout: dot, neato, twopi, circo, fdp
+        Default is 'dot'.
+
+    -v, --verbose
         Verbosely print processing information to stderr.
 
-    --help, -h
+    -h, --help
         Print this documentation.
 
-    --version
+    -V, --version
         Print program version number.
 
 SEE ALSO
     This script was inspired by his music2png.py and AsciiDoc
 
 LICENSE
-    Copyright (C) 2008 Gouichi Iisaka.
+    Copyright (C) 2008-2009 Gouichi Iisaka.
     Free use of this software is granted under the terms of
     the GNU General Public License (GPL).
     '''
     def __init__(self, argv=None):
         if not argv:
             argv = sys.argv
-        self.attrs = Struct()
-        self.usage_msg = '%prog [options] inputfile\n'
-        self.usage_msg += 'Version: %s\n' % __VERSION__
-        self.usage_msg += 'Copyright(c) 2008: %s' % __AUTHOR__
+
+        self.usage = '%prog [options] inputfile'
+        self.version = 'Version: %s\n' % __VERSION__
+        self.version += 'Copyright(c) 2008-2009: %s\n' % __AUTHOR__
 
         self.option_list = [
             Option("-o", "--outfile", action="store",
 		    dest="outfile",
 		    help="Output file"),
             Option("-L", "--layout", action="store",
-		    dest="layout", default="dot",
-		    help="Output file"),
+                    dest="layout", default="dot", type="choice",
+                    choices=['dot','neato','twopi','circo','fdp'],
+		    help="Layout type. LAYOUT=<dot|neato|twopi|circo|fdp>"),
             Option("--debug", action="store_true",
 		    dest="do_debug",
 		    help=SUPPRESS_HELP),
             Option("-v", "--verbose", action="store_true",
 		    dest="do_verbose", default=False,
 		    help="verbose output"),
-            Option("-V", "--version", action="store_true",
-		    dest="do_version",
-		    help="Print version"),
 	    ]
 
-        self.parser = OptionParser(option_list=self.option_list)
-        self.parser.set_usage(self.usage_msg)
+        self.parser = OptionParser( usage=self.usage, version=self.version,
+                                    option_list=self.option_list)
         (self.options, self.args) = self.parser.parse_args()
 
-	if self.options.do_version:
-            self.parser.print_usage()
-            sys.exit(1)
-
 	if len(self.args) != 1:
             self.parser.print_help()
             sys.exit(1)
             cmd = '%s -Tpng "%s" > "%s"' % (
                         self.options.layout, infile, outfile)
             self.systemcmd(cmd)
-            os.unlink(infile)
         finally:
             os.chdir(saved_cwd)
 
+        if not self.options.do_debug:
+            os.unlink(infile)
+
     def run(self):
         if self.options.infile == '-':
             if self.options.outfile is None: