[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
devs/felipealmeida/promises
Gustavo Lima Chaves 11 years ago
parent 45e8d67a78
commit 1bdf2bc528
  1. 2
      legacy/elementary/doc/Makefile.am
  2. 71
      legacy/elementary/doc/widget_hierarchy.py

@ -157,7 +157,7 @@ widget-preview: widget-build
done
widget-tree-figures: doc
$(srcdir)/widget_hierarchy.py --scan -d $(top_srcdir)/src/lib -o $(builddir)/widget_tree.p;
$(srcdir)/widget_hierarchy.py --scan $(top_srcdir)/src/lib -o $(builddir)/widget_tree.p;
$(srcdir)/widget_hierarchy.py --tree -i $(builddir)/widget_tree.p > $(builddir)/widgets_tree.dot;
dot -Tpng -o $(top_srcdir)/doc/img/elm-widget-tree.png $(top_builddir)/doc/widgets_tree.dot;
convert $(top_srcdir)/doc/img/elm-widget-tree.png $(top_srcdir)/doc/img/"widgets_tree.eps";

@ -6,8 +6,36 @@ import sys
import pickle
from optparse import OptionParser
def print_node(a, b, back=False):
print '"%s" -> "%s"' % (a, b), " [dir=back];" if back else ";"
def print_node(a, b, on_tree=False):
if on_tree:
rank = "source"
else:
rank = "same"
i_list = ifaces.get(a)
if i_list:
for iface in i_list:
if_instance = a + iface
print '"%s" [label="",shape=circle,width=0.2]' % if_instance
print '"%s" -> "%s" [label="%s", color=transparent]' \
% (if_instance, if_instance, iface)
print '{rank="%s" "%s" -> "%s" [arrowhead="none"];}' \
% (rank, if_instance, a)
i_list = ifaces.get(b)
if i_list:
for iface in i_list:
if_instance = b + iface
print '"%s" [label="",shape=circle,width=0.2]' % if_instance
print '"%s" -> "%s" [label="%s", color=transparent]' \
% (if_instance, if_instance, iface)
print '{rank="%s" "%s" -> "%s" [arrowhead="none"];}' \
% (rank, if_instance, b)
print '"%s" -> "%s"' % (a, b), '[arrowhead="empty"];' \
if on_tree else '[arrowtail="empty",dir=back];'
def topological_sort(dep_map, value):
hierarchy = []
@ -29,10 +57,17 @@ def hierachy_build(files_list):
for path in files_list:
contents = ''.join(l[:-1] for l in open(path))
m = re.search(class_re, contents)
iface_m = re.search(class_iface_re, contents)
if m is not None:
items.setdefault(m.group(3), []).append(m.group(1))
if m.group(2) != m.group(3):
cls_map[m.group(2)] = m.group(1)
if iface_m is not None:
items.setdefault(iface_m.group(3), []).append(iface_m.group(1))
if iface_m.group(2) != iface_m.group(3):
cls_map[iface_m.group(2)] = iface_m.group(1)
#hardcoding scrollable now, for brevity -- it may change in future
ifaces.setdefault(iface_m.group(1), []).append('scrollable')
for k, v in items.iteritems():
clsname = cls_map.get(k, k)
@ -50,16 +85,18 @@ def files_list_build(d):
#widget name, widget class, parent class
class_re = 'EVAS_SMART_SUBCLASS_NEW.*?,.*?_elm_(\w+).*?,.*?(\w+).*?,.*?(\w+)'
usage = "usage: %prog -s -d <DIRECTORY> -o <OUTPUT_FILE>\n" \
#widget name, widget class, parent class
class_iface_re = \
'EVAS_SMART_SUBCLASS_IFACE_NEW.*?,.*?_elm_(\w+).*?,.*?(\w+).*?,.*?(\w+)'
usage = "usage: %prog -s <DIRECTORY> -o <OUTPUT_FILE>\n" \
" %prog -w <WIDGET_NAME> -i <INPUT_FILE>\n" \
" %prog -t -i <INPUT_FILE>\n"
parser = OptionParser(usage=usage)
parser.add_option(
"-s", "--scan", action="store_true", dest="scan",
help="scan for .h/.c files and build the whole widget tree")
parser.add_option(
"-d", "--directory", dest="scan_dir", default=None, type="str",
help="directory where to scan for .h/.c files")
"-s", "--scan", dest="scan_dir", default=None, type="str",
help="scan for .h/.c files, at the given path, and build the whole" +
" widget tree")
parser.add_option(
"-o", "--output", dest="output_file", default=None, type="str",
help="path of the output scanning file (widget tree)")
@ -77,13 +114,13 @@ parser.add_option(
opts, args = parser.parse_args()
if (not opts.scan and not opts.widget and not opts.tree) \
or (opts.scan and opts.widget) \
or (opts.scan and opts.tree) or \
if (not opts.scan_dir and not opts.widget and not opts.tree) \
or (opts.scan_dir and opts.widget) \
or (opts.scan_dir and opts.tree) or \
(opts.tree and opts.widget):
sys.exit(parser.print_usage())
if opts.scan and (not opts.scan_dir or not opts.output_file):
if opts.scan_dir and not opts.output_file:
sys.exit(parser.print_usage())
if opts.widget and not opts.input_file:
@ -94,11 +131,12 @@ if opts.tree and not opts.input_file:
items = {}
hierarchy = {}
ifaces = {}
if opts.scan:
if opts.scan_dir:
files = files_list_build(opts.scan_dir)
hierachy_build(files)
pickle.dump(hierarchy, open(opts.output_file, "wb" ))
pickle.dump([hierarchy, ifaces], open(opts.output_file, "wb" ))
sys.exit()
if opts.tree:
@ -109,7 +147,8 @@ if opts.tree:
if not f:
sys.exit("Bad input file path")
hierarchy = pickle.load(f)
hierarchy, ifaces = pickle.load(f)
for cls, parent in hierarchy.items():
print_node(cls, parent, True);
@ -122,7 +161,7 @@ if opts.widget:
if not f:
sys.exit("Bad input file path")
hierarchy = pickle.load(f)
hierarchy, ifaces = pickle.load(f)
l = topological_sort(hierarchy, opts.widget)
def pairs(lst):

Loading…
Cancel
Save