#574070 graphviz: Please add a 'dot -T help' option to cleanly list plugin renderer formats.

Package:
graphviz
Source:
graphviz
Description:
rich set of graph drawing tools
Submitter:
"A. Costa"
Date:
2010-03-17 18:21:07 UTC
Severity:
wishlist
#574070#5
Date:
2010-03-16 04:02:56 UTC
From:
To:
Oddly enough, 'dot' almost has this feature, but the helpful output
itself is currently tricky to parse and list.

Model example; 'mplayer':

    mplayer -vo help | tail
        mpegpes	MPEG-PES to DVB card
        yuv4mpeg	yuv4mpeg output for mjpegtools
        png		PNG file
        jpeg		JPEG file
        gif89a		animated GIF output
        tga		Targa output
        pnm		PPM/PGM/PGMYUV file
        md5sum		md5sum of each frame

    112 audio & 235 video codecs

'man dot' asks users to guess & poll, or go online:

    % man dot | grep -A 17 "OUTPUT FORMATS"
    OUTPUT FORMATS
       Dot uses an extensible plugin mechanism for its  output  renderers,
       so to see what output formats your installation of dot supports you
       can use ``dot -Txxx'' (where xxx is an unlikely format)  and  check
       the  warning message.  Also, The plugin mechanism supports multiple
       implementations of the output formats.  To see  what  variants  are
       available, use, for example: ``dot -Tpng:'' and to force a particu-
       lar variant, use, for example: ``dot -Tpng:gd''

       Traditionally, dot supports the following: -Tps (PostScript), -Tsvg
       -Tsvgz  (Structured  Vector Graphics), -Tfig (XFIG graphics), -Tmif
       (FrameMaker graphics), -Thpgl (HP pen plotters), and -Tpcl  (Laser-
       jet  printers),  -Tpng  -Tgif  (bitmap graphics), -Tdia (GTK+ based
       diagrams), -Timap (imagemap files for httpd servers for  each  node
       or  edge that has a non(hynull "href" attribute.), -Tcmapx (client-
       side imagemap for use in html and xhtml).  Additional  less  common
       or   more   special-purpose   output   formats   can  be  found  at
http://www.graphviz.org/cvs/doc/info/output.html.)


(Bonus: if an 'mplayer'-like '-T help' option were added, most of those
two paragraphs won't be needed.)

When testing what the 'man' says, the user is surprised to find that
"the warning message" is close what a '-T help' option should be:

    # there's no 'help' graphics format, so try that...
    % dot -T help
    Format: "help" 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

The above listing is incomplete; subtypes exist:

    # show help for 'png'
    dot -Tpng:
    Format: "png:" not recognized. Use one of: png:cairo:cairo
    png:cairo:gd png:gd:gd

More than one format followed by only a colon (e.g. 'dia:') make 'dot'
wait for input, (another bug?), so getting a complete list is a kludgy
business.  Until something better comes along, here's one way to do it:

    # parse '-T' error from stderr, mine that for suboptions,
    # ending needless processes as they occur.
    % for f in $(dot -T help 2>&1 | sed 's/.*://') ;
	do  echo "Format: $f" ;
	    dot -T$f: & n=$! ;
	    sleep .1s ; kill -9 $n  ;
	done 2>&1 | grep Format | sed 's/.*: //g;s/ /\n/g'

On my system it shows 80 items.  Anyway, the 'mplayer -vo help' style
would be better.

HTH...

#574070#10
Date:
2010-03-16 19:18:26 UTC
From:
To:
A. Costa wrote:

Hi,

You might want to check out the -P option which outputs a graph of the
available plugins e.g.

	dot -Tsvg -P -o dotformats.svg

Of course it's not quite the same as the simple list that your script
produces, but it does show the requisite information.

Cheers,

	David.

#574070#15
Date:
2010-03-17 08:42:03 UTC
From:
To:
Cool tip, but with v2.20.2-8 +b1 it doesn't happen:

	% dot -Tsvg -P -o dotformats.svg 2>&1 | head -n 1 ; echo $?
	dot: option -P unrecognized
	0

The '0' error code is prolly another bug.  Was there a typo?  '-P'
isn't in the command line help or the manual.

	% { man dot ; dot  -h 2>&1 ;} | grep  '\-P'
	in  the  spirit  of Fruchterman and Reingold (cf. Software-Practice & Experience 21(11), 1991,

However it works, it'd be neat to see.  Come to think of it, every
command should have a nice 'dot' graph of options!  Given which,
there should be a standard invocation, (and preferably a standard
syntax for the output), something like the common option '-v' for
verbose... '-vdot', '-hdot', '-hgraph', '-hdag', or like that.

#574070#20
Date:
2010-03-17 18:24:22 UTC
From:
To:
A. Costa wrote:

Sorry I should have mentioned, I'm using version 2.26.3-2 which hit
testing a few days ago - you're right it's not present in the older version.

Cheers,

	David.