-
Notifications
You must be signed in to change notification settings - Fork 114
/
define.dot.erb
54 lines (49 loc) · 1.51 KB
/
define.dot.erb
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
digraph settings {
graph [rankdir=RL]
subgraph defaults {
<%
require 'set'
numbers = Set.new
tapping_resolution_formulas = Set.new
settings = {}
`grep -h -A1 '^#ifndef' keymap.dtsi.min device.dtsi.min | grep '^#define'`.lines.each do |define|
(_define, key, value) = define.chomp.split(/\s+/, 3)
case value
when /TAPPING_RESOLUTION ([+\-]) (\d+)/
warn({ formula: {key => $~} })
value = "#{$1}#{$2}".inspect
tapping_resolution_formulas << value
when /^["']/
warn({ string: {key => value} })
value = value.rstrip.inspect
when /^\d+$/
warn({ number: {key => value} })
numbers << value
value = "NUMBER_#{value}"
when "\\", /\(/
warn({ definition: {key => value} })
next # skip this setting -- it's a complex multi-line definition
end
settings[key] = value
%>
<%= key %> -> <%= value %>
<%
end
%>
<% tapping_resolution_formulas.each do |label| %>
<%= label %> -> TAPPING_RESOLUTION [color=red]
<% end %>
}
subgraph values {
graph [rank=same]
<% settings.values.grep(/^".*"$/).uniq.each do |string| %>
<%= string %> [label=<%= string %>, style=filled, fillcolor=cyan, shape=signature]
<% end %>
<% numbers.each do |number| %>
NUMBER_<%= number %> [label="<%= number %>", style=filled, fillcolor=yellow, shape=signature]
<% end %>
<% tapping_resolution_formulas.each do |label| %>
<%= label %> [label=<%= label %>, style=filled, fillcolor=salmon, shape=lpromoter]
<% end %>
}
}