From: Emden R. Gansner Date: Mon, 5 Sep 2016 20:35:47 +0000 (-0400) Subject: Add documentation on json output. X-Git-Tag: untagged-d1db4ad9a9fa8595330a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc6488018f3f55ace6b4046645578508643db08b;p=graphviz Add documentation on json output. --- diff --git a/doc/info/output.html b/doc/info/output.html index 678c2de5b..c9f49c1d8 100644 --- a/doc/info/output.html +++ b/doc/info/output.html @@ -5,6 +5,13 @@ Output Formats + + @@ -74,6 +81,11 @@ formats need to be interpreted in this manner.
jpeg
jpe JPEG + json +
json0 +
dot_json +
xdot_json +Dot graph represented in JSON format pct
pict PICT @@ -436,6 +448,35 @@ node or edge name. ,
jpe
Output JPEG compressed image files. +
json +,
json0 +,
dot_json +,
xdot_json +
These formats produce a JSON output encoding the DOT language. +Using json0 produces output in JSON format that contains the +same information produced by -Tdot. +Using json produces output in JSON format that contains the +same information produced by -Txdot. +Both of these assume the graph has been processed by one of the layout +algorithms. +The dot_json and xdot_json also produce JSON output similar to +to json0 and json, respectively, except they only use the +content of the graph on input. In particular, they do not assume that the +graph has been processed by any layout algorithm, and the only xdot information +appearing in the output was in the original input file. +

+The output produced by these follows the json schema shown below. +Note that the objects array has all of the subgraphs first, +followed by all of the nodes. The _gvid value is the index of +the subgraph or node in the objects array. This also holds +true for the edges in the objects array. Note that this format +allows clustered graphs, where edges can connect clusters as well as nodes. +

+ + +
pct ,
pict
Output in the Apple PICT file format. diff --git a/doc/info/schema.html b/doc/info/schema.html new file mode 100644 index 000000000..251c44365 --- /dev/null +++ b/doc/info/schema.html @@ -0,0 +1 @@ +
descriptionJSON representation of a graph encoding xdot attributes
titleGraphviz JSON
required
  • name
  • directed
  • strict
  • _subgraph_cnt
definitions
drawops
items
oneOf
$ref
#/definitions/ellipse
#/definitions/polygon
#/definitions/polyline
#/definitions/bspline
#/definitions/text
#/definitions/font_style
#/definitions/drawcolor
#/definitions/font
#/definitions/style
typearray
style
required
  • op
  • style
typeobject
properties
style
typestring
op
patternS
typestring
font_style
required
  • op
  • fontchar
typeobject
properties
op
patternt
typestring
fontchar
minimum0
typeinteger
maximum127
polygon
required
  • op
  • points
typeobject
properties
points
$ref#/definitions/pointlist
op
pattern[pP]
typestring
metanode
required
  • _gvid
  • name
typeobject
properties
_draw_
$ref#/definitions/drawops
name
typestring
descriptionThe node or subgraph name
_ldraw_
$ref#/definitions/drawops
_gvid
typeinteger
subgraphs
items
typeinteger
typearray
descriptionindex of a child subgraph
edges
items
typeinteger
typearray
descriptionindex of an edge in this subgraph
additionalProperties
typestring
nodes
items
typeinteger
typearray
descriptionindex of a node in this subgraph
titlenode or subgraph
color
pattern(#[0-9a-f]*)|(#[0-9a-f]{8})
typestring
text
required
  • op
  • pt
  • align
  • text
  • width
typeobject
properties
text
typestring
align
pattern[lcr]
typestring
op
patternT
typestring
pt
$ref#/definitions/point
width
typenumber
point
minItems2
items
typenumber
typearray
maxItems2
stop
required
  • frac
  • color
typeobject
properties
color
$ref#/definitions/color
frac
typenumber
drawcolor
required
  • op
  • grad
typeobject
properties
p0
oneOf
$ref
#/definitions/point
#/definitions/point3
p1
oneOf
$ref
#/definitions/point
#/definitions/point3
color
$ref#/definitions/color
stops
items
$ref#/definitions/stop
typearray
grad
enum
  • none
  • linear
  • radial
typestring
op
pattern[cC]
typestring
ellipse
required
  • op
  • rect
typeobject
properties
rect
$ref#/definitions/rectangle
op
pattern[eE]
typestring
bspline
required
  • op
  • points
typeobject
properties
points
$ref#/definitions/pointlist
op
pattern[bB]
typestring
edge
required
  • _gvid
  • tail
  • head
typeobject
properties
_hldraw_
$ref#/definitions/drawops
_tdraw_
$ref#/definitions/drawops
_draw_
$ref#/definitions/drawops
_ldraw_
$ref#/definitions/drawops
_gvid
typeinteger
tail
typeinteger
description_gvid of tail node
_tldraw_
$ref#/definitions/drawops
_hdraw_
$ref#/definitions/drawops
additionalProperties
typestring
head
typeinteger
description_gvid of tail head
titleedge
polyline
required
  • op
  • points
typeobject
properties
points
$ref#/definitions/pointlist
op
patternL
typestring
font
required
  • op
  • size
  • face
typeobject
properties
size
minimum0
typenumber
op
patternF
typestring
face
typestring
point3
minItems3
items
typenumber
typearray
maxItems3
rectangle
minItems4
items
typenumber
typearray
maxItems4
pointlist
items
$ref#/definitions/point
typearray
typeobject
properties
directed
typeboolean
descriptionTrue if the graph is directed
_draw_
$ref#/definitions/drawops
name
typestring
descriptionThe graph name
objects
items
$ref#/definitions/metanode
typearray
descriptionThe graph's subgraphs followed by the graph's nodes
_ldraw_
$ref#/definitions/drawops
strict
typeboolean
descriptionTrue if the graph is strict
edges
items
$ref#/definitions/edge
typearray
additionalProperties
typestring
_subgraph_cnt
typeinteger
descriptionNumber of subgraphs in the graph
\ No newline at end of file diff --git a/doc/infosrc/Makefile.old b/doc/infosrc/Makefile.old index 72391669d..d25cd09d6 100644 --- a/doc/infosrc/Makefile.old +++ b/doc/infosrc/Makefile.old @@ -1,11 +1,15 @@ # # Generator for on-line documentation. # -# Required tools: cc, dot, awk, ksh, yacc, gs. +# Required tools: cc, dot, awk, ksh, yacc, gs, python. # gs and awk are used in ps_to_jpg.sh # dot is used in mkarrows.sh, mkshapes.sh, mkstyles.sh, mktapers.sh, mksplines.sh # ps_to_png.sh and other make rules rely on netpbm tools # and ps2raster, which is part of the GMT library. +# +# python is used to run jconvert.py, which converts the json schema +# graphviz_json_schema.json to html. This also relies on the python +# package json2html. # # The main product are 7 web pages: # arrows.html - arrow_grammar @@ -83,7 +87,7 @@ A2GIF= aa_box.gif aa_lbox.gif aa_rbox.gif aa_obox.gif aa_olbox.gif aa_orbox.gif\ GIF = $(SGIF) $(AGIF) $(MGIF) $(A2GIF) $(XGIF) DOTS = html2.gv html3.gv html4.gv tee.gv HTML = attrs.html colors.html command.html lang.html output.html shapes.html \ - arrows.html + arrows.html schema.html INSTALL_FILES = $(HTML) $(DOTS) $(SGIF) $(AGIF) $(A2GIF) $(MGIF) $(XGIF) $(MJPG) $(MPNG) .SUFFIXES: .gv .gif .dot .png @@ -136,8 +140,9 @@ colors.html : colors.1 colors.n ../../lib/common/color_names ../../lib/common/sv cat colors.n >> colors.html rm -rf colortmp -output.html : output.1 output.2 outputs mkoutput.sh plugins.png +output.html : output.1 output.2 outputs mkoutput.sh plugins.png jconvert.py cat output.1 > output.html + ./jconvert.py graphviz_json_schema.json schema.html ./mkoutput.sh < outputs >> output.html cat output.2 >> output.html diff --git a/doc/infosrc/graphviz_json_schema.json b/doc/infosrc/graphviz_json_schema.json index e77e5db6d..a28b72e11 100644 --- a/doc/infosrc/graphviz_json_schema.json +++ b/doc/infosrc/graphviz_json_schema.json @@ -16,11 +16,13 @@ "description": "True if the graph is strict" }, "_subgraph_cnt": { - "type": "integer" + "type": "integer", + "description": "Number of subgraphs in the graph" }, "objects": { "type": "array", - "items": { "$ref": "#/definitions/metanode" } + "items": { "$ref": "#/definitions/metanode" }, + "description": "The graph's subgraphs followed by the graph's nodes" }, "edges": { "type": "array", diff --git a/doc/infosrc/mkoutput.sh b/doc/infosrc/mkoutput.sh index 9af35996f..cde583046 100755 --- a/doc/infosrc/mkoutput.sh +++ b/doc/infosrc/mkoutput.sh @@ -6,13 +6,30 @@ name= # storing the formats long name and description in the fullname # and desc arrays, respectively, indexed by the format name. # The initial line of an item has the format :name:long name +# +# Lines beginning with '#' are treated as comments, unless the +# following character is '<', in which case, it is assumed the +# remainder of the line contains a filename, whose contents will +# be read into the generared html file. OLDIFS="$IFS" IFS= while read line do c=${line:0:1} if [[ $c == '#' ]] - then continue + then + if [[ ${line:1:1} == '<' ]] + then + filename=${line:2} + filename=${filename##*( )} + filename=${filename%%*( )} + while read incline + do + txt="$txt${incline}\n" + done < $filename + else + continue + fi elif [[ $c == ':' ]] then if [[ -n "$name" ]] diff --git a/doc/infosrc/output.1 b/doc/infosrc/output.1 index 8d4eb339a..7eb74c843 100644 --- a/doc/infosrc/output.1 +++ b/doc/infosrc/output.1 @@ -5,6 +5,13 @@ Output Formats + + diff --git a/doc/infosrc/outputs b/doc/infosrc/outputs index 1b55db050..d973d2c26 100644 --- a/doc/infosrc/outputs +++ b/doc/infosrc/outputs @@ -55,6 +55,31 @@ See Pic language. :pov:POV-Ray markup language (prototype) Scene-description language for 3D modelling for the Persistence of Vision Raytracer. +:json/json0/dot_json/xdot_json:Dot graph represented in JSON format +These formats produce a JSON output encoding the DOT language. +Using json0 produces output in JSON format that contains the +same information produced by -Tdot. +Using json produces output in JSON format that contains the +same information produced by -Txdot. +Both of these assume the graph has been processed by one of the layout +algorithms. +The dot_json and xdot_json also produce JSON output similar to +to json0 and json, respectively, except they only use the +content of the graph on input. In particular, they do not assume that the +graph has been processed by any layout algorithm, and the only xdot information +appearing in the output was in the original input file. +

+The output produced by these follows the json schema shown below. +Note that the objects array has all of the subgraphs first, +followed by all of the nodes. The _gvid value is the index of +the subgraph or node in the objects array. This also holds +true for the edges in the objects array. Note that this format +allows clustered graphs, where edges can connect clusters as well as nodes. +

+ + :png:Portable Network Graphics format Produces output in the PNG (Portable Network Graphics) format.