summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGustavo Lima Chaves <glima@profusion.mobi>2012-07-04 21:41:38 +0000
committerGustavo Lima Chaves <glima@profusion.mobi>2012-07-04 21:41:38 +0000
commit77098806b5d1b0f7b761b90bc8984e93bbc10c6d (patch)
treebc5193537460496895cc71f028a33a6ca2565337 /doc
parenta31f48bfc098472d0d6e2f2d8cf87a2f3e55a35a (diff)
[elm] Taking interfaces into consideration on widget tree images creation.
It will assume the scrollable one only, for now (for brevity), but that can be extended later. SVN revision: 73308
Diffstat (limited to 'doc')
-rw-r--r--doc/Makefile.am2
-rwxr-xr-xdoc/widget_hierarchy.py71
2 files changed, 56 insertions, 17 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am
index b6a7671fb..1272e9262 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -157,7 +157,7 @@ widget-preview: widget-build
157 done 157 done
158 158
159widget-tree-figures: doc 159widget-tree-figures: doc
160 $(srcdir)/widget_hierarchy.py --scan -d $(top_srcdir)/src/lib -o $(builddir)/widget_tree.p; 160 $(srcdir)/widget_hierarchy.py --scan $(top_srcdir)/src/lib -o $(builddir)/widget_tree.p;
161 $(srcdir)/widget_hierarchy.py --tree -i $(builddir)/widget_tree.p > $(builddir)/widgets_tree.dot; 161 $(srcdir)/widget_hierarchy.py --tree -i $(builddir)/widget_tree.p > $(builddir)/widgets_tree.dot;
162 dot -Tpng -o $(top_srcdir)/doc/img/elm-widget-tree.png $(top_builddir)/doc/widgets_tree.dot; 162 dot -Tpng -o $(top_srcdir)/doc/img/elm-widget-tree.png $(top_builddir)/doc/widgets_tree.dot;
163 convert $(top_srcdir)/doc/img/elm-widget-tree.png $(top_srcdir)/doc/img/"widgets_tree.eps"; 163 convert $(top_srcdir)/doc/img/elm-widget-tree.png $(top_srcdir)/doc/img/"widgets_tree.eps";
diff --git a/doc/widget_hierarchy.py b/doc/widget_hierarchy.py
index a53d29a57..49e9941e6 100755
--- a/doc/widget_hierarchy.py
+++ b/doc/widget_hierarchy.py
@@ -6,8 +6,36 @@ import sys
6import pickle 6import pickle
7from optparse import OptionParser 7from optparse import OptionParser
8 8
9def print_node(a, b, back=False): 9def print_node(a, b, on_tree=False):
10 print '"%s" -> "%s"' % (a, b), " [dir=back];" if back else ";" 10 if on_tree:
11 rank = "source"
12 else:
13 rank = "same"
14
15 i_list = ifaces.get(a)
16 if i_list:
17 for iface in i_list:
18 if_instance = a + iface
19
20 print '"%s" [label="",shape=circle,width=0.2]' % if_instance
21 print '"%s" -> "%s" [label="%s", color=transparent]' \
22 % (if_instance, if_instance, iface)
23 print '{rank="%s" "%s" -> "%s" [arrowhead="none"];}' \
24 % (rank, if_instance, a)
25
26 i_list = ifaces.get(b)
27 if i_list:
28 for iface in i_list:
29 if_instance = b + iface
30
31 print '"%s" [label="",shape=circle,width=0.2]' % if_instance
32 print '"%s" -> "%s" [label="%s", color=transparent]' \
33 % (if_instance, if_instance, iface)
34 print '{rank="%s" "%s" -> "%s" [arrowhead="none"];}' \
35 % (rank, if_instance, b)
36
37 print '"%s" -> "%s"' % (a, b), '[arrowhead="empty"];' \
38 if on_tree else '[arrowtail="empty",dir=back];'
11 39
12def topological_sort(dep_map, value): 40def topological_sort(dep_map, value):
13 hierarchy = [] 41 hierarchy = []
@@ -29,10 +57,17 @@ def hierachy_build(files_list):
29 for path in files_list: 57 for path in files_list:
30 contents = ''.join(l[:-1] for l in open(path)) 58 contents = ''.join(l[:-1] for l in open(path))
31 m = re.search(class_re, contents) 59 m = re.search(class_re, contents)
60 iface_m = re.search(class_iface_re, contents)
32 if m is not None: 61 if m is not None:
33 items.setdefault(m.group(3), []).append(m.group(1)) 62 items.setdefault(m.group(3), []).append(m.group(1))
34 if m.group(2) != m.group(3): 63 if m.group(2) != m.group(3):
35 cls_map[m.group(2)] = m.group(1) 64 cls_map[m.group(2)] = m.group(1)
65 if iface_m is not None:
66 items.setdefault(iface_m.group(3), []).append(iface_m.group(1))
67 if iface_m.group(2) != iface_m.group(3):
68 cls_map[iface_m.group(2)] = iface_m.group(1)
69 #hardcoding scrollable now, for brevity -- it may change in future
70 ifaces.setdefault(iface_m.group(1), []).append('scrollable')
36 71
37 for k, v in items.iteritems(): 72 for k, v in items.iteritems():
38 clsname = cls_map.get(k, k) 73 clsname = cls_map.get(k, k)
@@ -50,16 +85,18 @@ def files_list_build(d):
50#widget name, widget class, parent class 85#widget name, widget class, parent class
51class_re = 'EVAS_SMART_SUBCLASS_NEW.*?,.*?_elm_(\w+).*?,.*?(\w+).*?,.*?(\w+)' 86class_re = 'EVAS_SMART_SUBCLASS_NEW.*?,.*?_elm_(\w+).*?,.*?(\w+).*?,.*?(\w+)'
52 87
53usage = "usage: %prog -s -d <DIRECTORY> -o <OUTPUT_FILE>\n" \ 88#widget name, widget class, parent class
89class_iface_re = \
90 'EVAS_SMART_SUBCLASS_IFACE_NEW.*?,.*?_elm_(\w+).*?,.*?(\w+).*?,.*?(\w+)'
91
92usage = "usage: %prog -s <DIRECTORY> -o <OUTPUT_FILE>\n" \
54 " %prog -w <WIDGET_NAME> -i <INPUT_FILE>\n" \ 93 " %prog -w <WIDGET_NAME> -i <INPUT_FILE>\n" \
55 " %prog -t -i <INPUT_FILE>\n" 94 " %prog -t -i <INPUT_FILE>\n"
56parser = OptionParser(usage=usage) 95parser = OptionParser(usage=usage)
57parser.add_option( 96parser.add_option(
58 "-s", "--scan", action="store_true", dest="scan", 97 "-s", "--scan", dest="scan_dir", default=None, type="str",
59 help="scan for .h/.c files and build the whole widget tree") 98 help="scan for .h/.c files, at the given path, and build the whole" +
60parser.add_option( 99 " widget tree")
61 "-d", "--directory", dest="scan_dir", default=None, type="str",
62 help="directory where to scan for .h/.c files")
63parser.add_option( 100parser.add_option(
64 "-o", "--output", dest="output_file", default=None, type="str", 101 "-o", "--output", dest="output_file", default=None, type="str",
65 help="path of the output scanning file (widget tree)") 102 help="path of the output scanning file (widget tree)")
@@ -77,13 +114,13 @@ parser.add_option(
77 114
78opts, args = parser.parse_args() 115opts, args = parser.parse_args()
79 116
80if (not opts.scan and not opts.widget and not opts.tree) \ 117if (not opts.scan_dir and not opts.widget and not opts.tree) \
81 or (opts.scan and opts.widget) \ 118 or (opts.scan_dir and opts.widget) \
82 or (opts.scan and opts.tree) or \ 119 or (opts.scan_dir and opts.tree) or \
83 (opts.tree and opts.widget): 120 (opts.tree and opts.widget):
84 sys.exit(parser.print_usage()) 121 sys.exit(parser.print_usage())
85 122
86if opts.scan and (not opts.scan_dir or not opts.output_file): 123if opts.scan_dir and not opts.output_file:
87 sys.exit(parser.print_usage()) 124 sys.exit(parser.print_usage())
88 125
89if opts.widget and not opts.input_file: 126if opts.widget and not opts.input_file:
@@ -94,11 +131,12 @@ if opts.tree and not opts.input_file:
94 131
95items = {} 132items = {}
96hierarchy = {} 133hierarchy = {}
134ifaces = {}
97 135
98if opts.scan: 136if opts.scan_dir:
99 files = files_list_build(opts.scan_dir) 137 files = files_list_build(opts.scan_dir)
100 hierachy_build(files) 138 hierachy_build(files)
101 pickle.dump(hierarchy, open(opts.output_file, "wb" )) 139 pickle.dump([hierarchy, ifaces], open(opts.output_file, "wb" ))
102 sys.exit() 140 sys.exit()
103 141
104if opts.tree: 142if opts.tree:
@@ -109,7 +147,8 @@ if opts.tree:
109 if not f: 147 if not f:
110 sys.exit("Bad input file path") 148 sys.exit("Bad input file path")
111 149
112 hierarchy = pickle.load(f) 150 hierarchy, ifaces = pickle.load(f)
151
113 for cls, parent in hierarchy.items(): 152 for cls, parent in hierarchy.items():
114 print_node(cls, parent, True); 153 print_node(cls, parent, True);
115 154
@@ -122,7 +161,7 @@ if opts.widget:
122 if not f: 161 if not f:
123 sys.exit("Bad input file path") 162 sys.exit("Bad input file path")
124 163
125 hierarchy = pickle.load(f) 164 hierarchy, ifaces = pickle.load(f)
126 l = topological_sort(hierarchy, opts.widget) 165 l = topological_sort(hierarchy, opts.widget)
127 166
128 def pairs(lst): 167 def pairs(lst):