Debian Codegraph @

gographviz.go

raw symbols SCIP
1 //Copyright 2013 GoGraphviz Authors
2 //
3 //Licensed under the Apache License, Version 2.0 (the "License");
4 //you may not use this file except in compliance with the License.
5 //You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 //Unless required by applicable law or agreed to in writing, software
10 //distributed under the License is distributed on an "AS IS" BASIS,
11 //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 //See the License for the specific language governing permissions and
13 //limitations under the License.
14
15 //Package gographviz provides parsing for the DOT grammar into
16 //an abstract syntax tree representing a graph,
17 //analysis of the abstract syntax tree into a more usable structure,
18 //and writing back of this structure into the DOT format.
19 package gographviz
20
21 import (
22 "github.com/awalterschulze/gographviz/ast"
23 "github.com/awalterschulze/gographviz/internal/parser"
24 )
25
26 var _ Interface = NewGraph()
27
28 //Interface allows you to parse the graph into your own structure.
29 type Interface interface {
30 SetStrict(strict bool) error
31 SetDir(directed bool) error
32 SetName(name string) error
33 AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string) error
34 AddEdge(src, dst string, directed bool, attrs map[string]string) error
35 AddNode(parentGraph string, name string, attrs map[string]string) error
36 AddAttr(parentGraph string, field, value string) error
37 AddSubGraph(parentGraph string, name string, attrs map[string]string) error
38 String() string
39 }
40
41 //Parse parses the buffer into a abstract syntax tree representing the graph.
42 func Parse(buf []byte) (*ast.Graph, error) {
43 return parser.ParseBytes(buf)
44 }
45
46 //ParseString parses the buffer into a abstract syntax tree representing the graph.
47 func ParseString(buf string) (*ast.Graph, error) {
48 return parser.ParseBytes([]byte(buf))
49 }
50
51 //Read parses and creates a new Graph from the data.
52 func Read(buf []byte) (*Graph, error) {
53 st, err := Parse(buf)
54 if err != nil {
55 return nil, err
56 }
57 return NewAnalysedGraph(st)
58 }