forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphviz.d.ts
93 lines (68 loc) · 2.83 KB
/
graphviz.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Type definitions for Graphviz 0.0.8
// Project: https://github.com/glejeune/node-graphviz
// Definitions by: Matt Frantz <https://github.com/mhfrantz/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// graphviz.d.ts
declare module 'graphviz' {
export interface HasAttributes {
set(name: string, value: any): void;
get(name: string): any;
}
export interface Node extends HasAttributes {
}
export interface Edge extends HasAttributes {
}
export interface OutputCallback {
(data: string): void;
}
export interface ErrorCallback {
(code: number, stdout: string, stderr: string): void;
}
export interface RenderOptions {
type: string; // output file type (png, jpeg, ps, ...)
use: string; // Graphviz command to use (dot, neato, ...)
path: string; // GraphViz path
G: any; // graph options
N: any; // node options
E: any; // edge options
}
export interface Graph extends HasAttributes {
addNode(id: string, attrs?: any): Node;
nodeCount(): number;
// TODO: Use union types when we have TS 1.4
addEdge(nodeOne: string, nodeTwo: string, attrs?: any): Edge;
addEdge(nodeOne: string, nodeTwo: Node, attrs?: any): Edge;
addEdge(nodeOne: Node, nodeTwo: string, attrs?: any): Edge;
addEdge(nodeOne: Node, nodeTwo: Node, attrs?: any): Edge;
edgeCount(): number;
// Subgraph (cluster) API
addCluster(id: string): Graph;
getCluster(id: string): Graph;
clusterCount(): number;
setNodeAttribut(name: string, value: any): void;
getNodeAttribut(name: string): any;
setEdgeAttribut(name: string, value: any): void;
getEdgeAttribut(name: string): any;
to_dot(): string;
// Graphviz command to use (dot, neato, ...)
use: string;
// Path containing Graphviz binaries.
setGraphVizPath(directoryPath: string): void;
// TODO: Use union types when we can have TS 1.4
render(type: string, filename: string, errback?: ErrorCallback): void;
render(options: RenderOptions, filename: string, errback?: ErrorCallback): void;
render(type: string, callback: OutputCallback, errback?: ErrorCallback): void;
render(options: RenderOptions, callback: OutputCallback, errback?: ErrorCallback): void;
// alias for render
output(type: string, filename: string, errback?: ErrorCallback): void;
output(options: RenderOptions, filename: string, errback?: ErrorCallback): void;
output(type: string, callback: OutputCallback, errback?: ErrorCallback): void;
output(options: RenderOptions, callback: OutputCallback, errback?: ErrorCallback): void;
}
export function graph(id: string): Graph;
export function digraph(id: string): Graph;
interface ParseCallback {
(graph: Graph): void;
}
export function parse(path: string, callback: ParseCallback, errback?: ErrorCallback): void;
}