MCPcopy Index your code
hub / github.com/nodejs/node / WriteGraph

Function WriteGraph

tools/gyp/tools/graphviz.py:43–82  ·  view source on GitHub ↗

Print a graphviz graph to stdout. |edges| is a map of target to a list of other targets it depends on.

(edges)

Source from the content-addressed store, hash-verified

41
42
43def WriteGraph(edges):
44 """Print a graphviz graph to stdout.
45 |edges| is a map of target to a list of other targets it depends on."""
46
47 # Bucket targets by file.
48 files = collections.defaultdict(list)
49 for src, dst in edges.items():
50 build_file, target_name, _toolset = ParseTarget(src)
51 files[build_file].append(src)
52
53 print("digraph D {")
54 print(" fontsize=8") # Used by subgraphs.
55 print(" node [fontsize=8]")
56
57 # Output nodes by file. We must first write out each node within
58 # its file grouping before writing out any edges that may refer
59 # to those nodes.
60 for filename, targets in files.items():
61 if len(targets) == 1:
62 # If there's only one node for this file, simplify
63 # the display by making it a box without an internal node.
64 target = targets[0]
65 build_file, target_name, _toolset = ParseTarget(target)
66 print(f' "{target}" [shape=box, label="{filename}\\n{target_name}"]')
67 else:
68 # Group multiple nodes together in a subgraph.
69 print(' subgraph "cluster_%s" {' % filename)
70 print(' label = "%s"' % filename)
71 for target in targets:
72 build_file, target_name, _toolset = ParseTarget(target)
73 print(f' "{target}" [label="{target_name}"]')
74 print(" }")
75
76 # Now that we've placed all the nodes within subgraphs, output all
77 # the edges between nodes.
78 for src, dsts in edges.items():
79 for dst in dsts:
80 print(f' "{src}" -> "{dst}"')
81
82 print("}")
83
84
85def main():

Callers 1

mainFunction · 0.85

Calls 4

ParseTargetFunction · 0.85
printFunction · 0.50
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected