diff options
Diffstat (limited to 'source-builder/sb/asciidoc/filters/graphviz')
3 files changed, 0 insertions, 392 deletions
diff --git a/source-builder/sb/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt b/source-builder/sb/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt deleted file mode 100644 index 4be6ba9..0000000 --- a/source-builder/sb/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt +++ /dev/null @@ -1,170 +0,0 @@ -= Graphviz filter for AsciiDoc = - -Author: Gouichi Iisaka - -Version: 1.1.3 - -== Introduction == - -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. - -== Examples == - -=== Simple === -..................................................................... -[graphviz] ---------------------------------------------------------------------- -digraph G { rankdir=LR; Graphviz->AsciiDoc->HTML} ---------------------------------------------------------------------- -..................................................................... - -[graphviz] ---------------------------------------------------------------------- -digraph G { rankdir=LR; Graphviz->AsciiDoc->HTML} ---------------------------------------------------------------------- - -=== Using options === -..................................................................... -["graphviz", "sample2.png"] ---------------------------------------------------------------------- -digraph automata_0 { - size ="8.5, 11"; - node [shape = circle]; - 0 [ style = filled, color=lightgrey ]; - 2 [ shape = doublecircle ]; - 0 -> 2 [ label = "a " ]; - 0 -> 1 [ label = "other " ]; - 1 -> 2 [ label = "a " ]; - 1 -> 1 [ label = "other " ]; - 2 -> 2 [ label = "a " ]; - 2 -> 1 [ label = "other " ]; - "Machine: a" [ shape = plaintext ]; -} ---------------------------------------------------------------------- -..................................................................... - -["graphviz", "sample2.png"] ---------------------------------------------------------------------- -digraph automata_0 { - size ="8.5, 11"; - node [shape = circle]; - 0 [ style = filled, color=lightgrey ]; - 2 [ shape = doublecircle ]; - 0 -> 2 [ label = "a " ]; - 0 -> 1 [ label = "other " ]; - 1 -> 2 [ label = "a " ]; - 1 -> 1 [ label = "other " ]; - 2 -> 2 [ label = "a " ]; - 2 -> 1 [ label = "other " ]; - "Machine: a" [ shape = plaintext ]; -} ---------------------------------------------------------------------- - -=== Using Layout === - -..................................................................... -["graphviz", "sample3.png", "dot"] ---------------------------------------------------------------------- -digraph finite_state_machine { - rankdir=LR; - size="8,5" - node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; - node [shape = circle]; - LR_0 -> LR_2 [ label = "SS(B)" ]; - LR_0 -> LR_1 [ label = "SS(S)" ]; - LR_1 -> LR_3 [ label = "S($end)" ]; - LR_2 -> LR_6 [ label = "SS(b)" ]; - LR_2 -> LR_5 [ label = "SS(a)" ]; - LR_2 -> LR_4 [ label = "S(A)" ]; - LR_5 -> LR_7 [ label = "S(b)" ]; - LR_5 -> LR_5 [ label = "S(a)" ]; - LR_6 -> LR_6 [ label = "S(b)" ]; - LR_6 -> LR_5 [ label = "S(a)" ]; - LR_7 -> LR_8 [ label = "S(b)" ]; - LR_7 -> LR_5 [ label = "S(a)" ]; - LR_8 -> LR_6 [ label = "S(b)" ]; - LR_8 -> LR_5 [ label = "S(a)" ]; -} ---------------------------------------------------------------------- -..................................................................... - -["graphviz", "sample3.png", "dot"] ---------------------------------------------------------------------- -digraph finite_state_machine { - rankdir=LR; - size="8,5" - node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; - node [shape = circle]; - LR_0 -> LR_2 [ label = "SS(B)" ]; - LR_0 -> LR_1 [ label = "SS(S)" ]; - LR_1 -> LR_3 [ label = "S($end)" ]; - LR_2 -> LR_6 [ label = "SS(b)" ]; - LR_2 -> LR_5 [ label = "SS(a)" ]; - LR_2 -> LR_4 [ label = "S(A)" ]; - LR_5 -> LR_7 [ label = "S(b)" ]; - LR_5 -> LR_5 [ label = "S(a)" ]; - LR_6 -> LR_6 [ label = "S(b)" ]; - LR_6 -> LR_5 [ label = "S(a)" ]; - LR_7 -> LR_8 [ label = "S(b)" ]; - LR_7 -> LR_5 [ label = "S(a)" ]; - LR_8 -> LR_6 [ label = "S(b)" ]; - LR_8 -> LR_5 [ label = "S(a)" ]; - } ---------------------------------------------------------------------- - - -== Layout == - -Layout for graphviz as follows. The default is `dot'. - - *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. - - *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). diff --git a/source-builder/sb/asciidoc/filters/graphviz/graphviz-filter.conf b/source-builder/sb/asciidoc/filters/graphviz/graphviz-filter.conf deleted file mode 100644 index f1ca264..0000000 --- a/source-builder/sb/asciidoc/filters/graphviz/graphviz-filter.conf +++ /dev/null @@ -1,53 +0,0 @@ -# -# AsciiDoc Graphviz filter configuration file. -# -# Version: 1.0 -# Gouici Iisaka <iisaka51 at gmail dot com> - -[graphviz-filter-style] -# When the filter output image is data-uri encoded write it to the indir -# (instead of the outdir) so that encoder can find it. -ifndef::data-uri[] -graphviz-style=template="graphviz{format?-{format}}-block",subs=(),posattrs=("style","target","layout","format"),filter='graphviz2png.py {verbose?-v} -o "{outdir={indir}}/{imagesdir=}{imagesdir?/}{target}" -L {layout=dot} -F {format=png} -' -endif::data-uri[] -ifdef::data-uri[] -graphviz-style=template="graphviz{format?-{format}}-block",subs=(),posattrs=("style","target","layout","format"),filter='graphviz2png.py {verbose?-v} -o "{indir={outdir}}/{imagesdir=}{imagesdir?/}{target}" -L {layout=dot} -F {format=png} -' -endif::data-uri[] - -[blockdef-open] -template::[graphviz-filter-style] - -[blockdef-listing] -template::[graphviz-filter-style] - -[paradef-default] -template::[graphviz-filter-style] - -[graphviz-block] -template::[filter-image-blockmacro] - -# EXPERIMENTAL: xhtml11 backend SVG image block. -ifdef::basebackend-xhtml11[] -[graphviz-svg-block] -<div class="imageblock"{id? id="{id}"}{align? style="text-align:{align};"}{float? style="float:{float};"}> -<div class="content"> -<a class="image" href="{link}"> -<object data="{imagesdir=}{imagesdir?/}{target}" type="image/svg+xml" /> -{link#}</a> -</div> -<div class="title">{caption={figure-caption} {counter:figure-number}. }{title}</div> -</div> -endif::basebackend-xhtml11[] - -# -# DEPRECATED: Pre 8.2.7 filter definition. -# -[blockdef-graphviz] -delimiter=^graphviz~{4,}$ -template=graphviz-block -presubs=none -filter=graphviz2png.py {verbose?-v} -o "{outdir={indir}}/{target}" -L {layout=dot} - -posattrs=target,format -# -# DEPRECATED: End -# diff --git a/source-builder/sb/asciidoc/filters/graphviz/graphviz2png.py b/source-builder/sb/asciidoc/filters/graphviz/graphviz2png.py deleted file mode 100755 index a3d43f5..0000000 --- a/source-builder/sb/asciidoc/filters/graphviz/graphviz2png.py +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env python - -import os, sys, subprocess -from optparse import * - -__AUTHOR__ = "Gouichi Iisaka <iisaka51@gmail.com>" -__VERSION__ = '1.1.4' - -class EApp(Exception): - '''Application specific exception.''' - pass - -class Application(): - ''' -NAME - graphviz2png - Converts textual graphviz notation to PNG file - -SYNOPSIS - graphviz2png [options] INFILE - -DESCRIPTION - This filter reads Graphviz notation text from the input file - INFILE (or stdin if INFILE is -), converts it to a PNG image file. - - -OPTIONS - -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. - - -L LAYOUT, --layout=LAYOUT - Graphviz layout: dot, neato, twopi, circo, fdp - Default is 'dot'. - - -F FORMAT, --format=FORMAT - Graphviz output format: png, svg, or any other format Graphviz - supports. Run dot -T? to get the full list. - Default is 'png'. - - -v, --verbose - Verbosely print processing information to stderr. - - -h, --help - Print this documentation. - - -V, --version - Print program version number. - -SEE ALSO - graphviz(1) - -AUTHOR - Written by Gouichi Iisaka, <iisaka51@gmail.com> - Format support added by Elmo Todurov, <todurov@gmail.com> - -THANKS - Stuart Rackham, <srackham@gmail.com> - This script was inspired by his music2png.py and AsciiDoc - -LICENSE - 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): - # Run dot, get the list of supported formats. It's prefixed by some junk. - format_output = subprocess.Popen(["dot", "-T?"], stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[1] - # The junk contains : and ends with :. So we split it, then strip the final endline, then split the list for future usage. - supported_formats = format_output.split(": ")[2][:-1].split(" ") - - if not argv: - argv = sys.argv - - 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", type="choice", - choices=['dot','neato','twopi','circo','fdp'], - help="Layout type. LAYOUT=<dot|neato|twopi|circo|fdp>"), - Option("-F", "--format", action="store", - dest="format", default="png", type="choice", - choices=supported_formats, - help="Format type. FORMAT=<" + "|".join(supported_formats) + ">"), - 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"), - ] - - self.parser = OptionParser( usage=self.usage, version=self.version, - option_list=self.option_list) - (self.options, self.args) = self.parser.parse_args() - - if len(self.args) != 1: - self.parser.print_help() - sys.exit(1) - - self.options.infile = self.args[0] - - def systemcmd(self, cmd): - if self.options.do_verbose: - msg = 'Execute: %s' % cmd - sys.stderr.write(msg + os.linesep) - else: - cmd += ' 2>%s' % os.devnull - if os.system(cmd): - raise EApp, 'failed command: %s' % cmd - - def graphviz2png(self, infile, outfile): - '''Convert Graphviz notation in file infile to - PNG file named outfile.''' - - outfile = os.path.abspath(outfile) - outdir = os.path.dirname(outfile) - - if not os.path.isdir(outdir): - raise EApp, 'directory does not exist: %s' % outdir - - basefile = os.path.splitext(outfile)[0] - saved_cwd = os.getcwd() - os.chdir(outdir) - try: - cmd = '%s -T%s "%s" > "%s"' % ( - self.options.layout, self.options.format, infile, outfile) - self.systemcmd(cmd) - finally: - os.chdir(saved_cwd) - - if not self.options.do_debug: - os.unlink(infile) - - def run(self): - if self.options.format == '': - self.options.format = 'png' - - if self.options.infile == '-': - if self.options.outfile is None: - sys.stderr.write('OUTFILE must be specified') - sys.exit(1) - infile = os.path.splitext(self.options.outfile)[0] + '.txt' - lines = sys.stdin.readlines() - open(infile, 'w').writelines(lines) - - if not os.path.isfile(infile): - raise EApp, 'input file does not exist: %s' % infile - - if self.options.outfile is None: - outfile = os.path.splitext(infile)[0] + '.png' - else: - outfile = self.options.outfile - - self.graphviz2png(infile, outfile) - - # To suppress asciidoc 'no output from filter' warnings. - if self.options.infile == '-': - sys.stdout.write(' ') - -if __name__ == "__main__": - app = Application() - app.run() |