summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-02-18 09:33:22 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-02-18 09:35:53 +0100
commit0af53f4bc6a42d0cd9b08647f8f40ea10140f14b (patch)
treecd4c001ddccf7dc815d0ad95e03dfc54b91bdfc5
parentbfbe038921176f9134021ce33894d7128dc1f02e (diff)
Pyolian: improve a bit the namespace generation
I still think that namespaces should be directly exposed by eolian. Currently pyolian provide a namespace implementation but it's hard to get it right, and it should be really shared between all eolian users.
-rw-r--r--src/scripts/gendoc/doc_start.template6
-rwxr-xr-xsrc/scripts/gendoc/gendoc.py64
-rw-r--r--src/scripts/gendoc/namespaces.template83
-rw-r--r--src/scripts/pyolian/eolian.py48
4 files changed, 153 insertions, 48 deletions
diff --git a/src/scripts/gendoc/doc_start.template b/src/scripts/gendoc/doc_start.template
index aeeed38fd3..57526ca51f 100644
--- a/src/scripts/gendoc/doc_start.template
+++ b/src/scripts/gendoc/doc_start.template
@@ -10,12 +10,6 @@ Pratically there is nothing python related currently in this documentation,
10so it can be considered valid for all languages. 10so it can be considered valid for all languages.
11 11
12 12
13^** Some numbers just for information **^^
14<!--(for label, val in totals)-->
15| ${label}$ | **${val}$** |
16<!--(end)-->
17
18
19<!--(for ns in nspaces)--> 13<!--(for ns in nspaces)-->
20===== ${ns.name}$ (namespace) ===== 14===== ${ns.name}$ (namespace) =====
21 15
diff --git a/src/scripts/gendoc/gendoc.py b/src/scripts/gendoc/gendoc.py
index d3286229c6..d0fc5ebf28 100755
--- a/src/scripts/gendoc/gendoc.py
+++ b/src/scripts/gendoc/gendoc.py
@@ -76,6 +76,47 @@ def page_path_for_object(obj):
76 return os.path.join(args.root_path, *path, output_file) 76 return os.path.join(args.root_path, *path, output_file)
77 77
78 78
79# render a (temporary) page for analizying the namespaces hierarchy
80t = Template('namespaces.template')
81nspaces = [ ns for ns in eolian_db.all_namespaces
82 if ns.name.startswith(args.namespace) ]
83
84tot_classes = tot_regulars = tot_abstracts = tot_mixins = tot_ifaces = 0
85tot_enums = tot_structs = tot_aliases = 0
86for ns in nspaces:
87 for cls in ns.classes:
88 tot_classes += 1
89 if cls.type == eolian.Eolian_Class_Type.REGULAR:
90 tot_regulars += 1
91 elif cls.type == eolian.Eolian_Class_Type.ABSTRACT:
92 tot_abstracts += 1
93 elif cls.type == eolian.Eolian_Class_Type.MIXIN:
94 tot_mixins += 1
95 elif cls.type == eolian.Eolian_Class_Type.INTERFACE:
96 tot_ifaces += 1
97 tot_enums += len(ns.enums)
98 tot_structs += len(ns.structs)
99 tot_aliases += len(ns.aliases)
100
101
102totals = [
103 ('Namespaces', len(nspaces)),
104 ('ALL Classes', tot_classes),
105 ('Regular classes', tot_regulars),
106 ('Abstract classes', tot_abstracts),
107 ('Mixins', tot_mixins),
108 ('Interfaces', tot_ifaces),
109 ('Enums', tot_enums),
110 ('Structs', tot_structs),
111 ('Aliases', tot_aliases),
112]
113
114root_ns = eolian_db.namespace_get_by_name(args.namespace)
115
116output_file = os.path.join(args.root_path,'data','pages','develop','api','namespaces.txt')
117t.render(output_file, args.verbose, root_ns=root_ns, totals=totals)
118
119
79# render the main start.txt page 120# render the main start.txt page
80if args.step in ('start', None): 121if args.step in ('start', None):
81 t = Template('doc_start.template') 122 t = Template('doc_start.template')
@@ -83,29 +124,8 @@ if args.step in ('start', None):
83 nspaces = [ ns for ns in eolian_db.all_namespaces 124 nspaces = [ ns for ns in eolian_db.all_namespaces
84 if ns.name.startswith(args.namespace) ] 125 if ns.name.startswith(args.namespace) ]
85 126
86 tot_classes = tot_regulars = tot_abstracts = tot_mixins = tot_ifaces = 0
87 for ns in nspaces:
88 for cls in ns.classes:
89 tot_classes += 1
90 if cls.type == eolian.Eolian_Class_Type.REGULAR:
91 tot_regulars += 1
92 elif cls.type == eolian.Eolian_Class_Type.ABSTRACT:
93 tot_abstracts += 1
94 elif cls.type == eolian.Eolian_Class_Type.MIXIN:
95 tot_mixins += 1
96 elif cls.type == eolian.Eolian_Class_Type.INTERFACE:
97 tot_ifaces += 1
98 totals = [
99 ('Namespaces', len(nspaces)),
100 ('ALL Classes', tot_classes),
101 ('Regular classes', tot_regulars),
102 ('Abstract classes', tot_abstracts),
103 ('Mixins', tot_mixins),
104 ('Interfaces', tot_ifaces),
105 ]
106
107 output_file = os.path.join(args.root_path,'data','pages','develop','api','start.txt') 127 output_file = os.path.join(args.root_path,'data','pages','develop','api','start.txt')
108 t.render(output_file, args.verbose, nspaces=nspaces, totals=totals) 128 t.render(output_file, args.verbose, nspaces=nspaces)
109 129
110 130
111# render a page for each Class 131# render a page for each Class
diff --git a/src/scripts/gendoc/namespaces.template b/src/scripts/gendoc/namespaces.template
new file mode 100644
index 0000000000..02c071b634
--- /dev/null
+++ b/src/scripts/gendoc/namespaces.template
@@ -0,0 +1,83 @@
1~~Title: EFL Namespaces~~
2
3#!##############################################################################
4#!#### CLS_LINK(cls) #########################################################
5#!##############################################################################
6<!--(macro CLS_LINK)-->
7[[:develop:api#!
8 <!--(for n in cls.namespaces)-->
9:${n.lower()}$#!
10 <!--(end)-->
11:${cls.name.lower()}$|${cls.name}$]]
12<!--(end)-->
13
14#!##############################################################################
15#!#### TYPEDECL_LINK(typedecl) ###############################################
16#!##############################################################################
17<!--(macro TYPEDECL_LINK)-->
18[[:develop:api#!
19 <!--(for n in typedecl.namespaces)-->
20:${n.lower()}$#!
21 <!--(end)-->
22:${typedecl.name.lower()}$|${typedecl.name}$]]
23<!--(end)-->
24
25#!##############################################################################
26#!#### NAMESPACE_ITEM(ns) ####################################################
27#!##############################################################################
28<!--(macro NAMESPACE_ITEM)-->
29**${ns.name}$** #!
30 <!--(if len(ns.regulars))-->
31 \\ Classes: <!--(for cls in ns.regulars)--> ${CLS_LINK(cls=cls)}$, <!--(end)--> #!
32 <!--(end)-->
33 <!--(if len(ns.abstracts))-->
34 \\ Abstracts: <!--(for cls in ns.abstracts)--> ${CLS_LINK(cls=cls)}$, <!--(end)--> #!
35 <!--(end)-->
36 <!--(if len(ns.mixins))-->
37 \\ Mixins: <!--(for cls in ns.mixins)--> ${CLS_LINK(cls=cls)}$, <!--(end)--> #!
38 <!--(end)-->
39 <!--(if len(ns.interfaces))-->
40 \\ Interfaces: <!--(for cls in ns.interfaces)--> ${CLS_LINK(cls=cls)}$, <!--(end)--> #!
41 <!--(end)-->
42 <!--(if len(ns.structs))-->
43 \\ Structs: <!--(for struct in ns.structs)--> ${TYPEDECL_LINK(typedecl=struct)}$, <!--(end)--> #!
44 <!--(end)-->
45 <!--(if len(ns.enums))-->
46 \\ Enums: <!--(for enum in ns.enums)--> ${TYPEDECL_LINK(typedecl=enum)}$, <!--(end)--> #!
47 <!--(end)-->
48 <!--(if len(ns.aliases))-->
49 \\ Aliases: <!--(for alias in ns.aliases)--> ${TYPEDECL_LINK(typedecl=alias)}$, <!--(end)--> #!
50 <!--(end)-->
51<!--(end)-->
52
53
54====== Unified-API namespaces hierarchy ======
55This page is just a temporary work to analyze the namespaces in the new API
56
57
58^** Some numbers just for information **^^
59<!--(for label, val in totals)-->
60| ${label}$ | **${val}$** |
61<!--(end)-->
62
63
64
65===== Namespaces hierarchy =====
66
67
68 * ${NAMESPACE_ITEM(ns=root_ns)}$
69<!--(for sub in root_ns.sub_namespaces)-->
70 * ${NAMESPACE_ITEM(ns=sub)}$
71 <!--(for sub in sub.sub_namespaces)-->
72 * ${NAMESPACE_ITEM(ns=sub)}$
73 <!--(for sub in sub.sub_namespaces)-->
74 * ${NAMESPACE_ITEM(ns=sub)}$
75 <!--(for sub in sub.sub_namespaces)-->
76 * ${NAMESPACE_ITEM(ns=sub)}$
77 <!--(end)-->
78 <!--(end)-->
79 <!--(end)-->
80<!--(end)-->
81
82
83
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 6e3b52b3ec..d62e74bec2 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -510,48 +510,56 @@ class Namespace(object):
510 return self._name.split('.') 510 return self._name.split('.')
511 511
512 @property 512 @property
513 def sub_namespaces(self):
514 base = self._name + '.'
515 deep = self._name.count('.') + 1
516 return [ ns for ns in self._unit.all_namespaces
517 if ns.name.startswith(base) and ns.name.count('.') == deep ]
518
519
520 @property
513 def classes(self): 521 def classes(self):
514 return [ c for c in self._unit.all_classes 522 return sorted([ c for c in self._unit.all_classes
515 if c.namespace == self._name ] 523 if c.namespace == self._name ])
516 524
517 @property 525 @property
518 def regulars(self): 526 def regulars(self):
519 return [ c for c in self._unit.all_classes 527 return sorted([ c for c in self._unit.all_classes
520 if c.type == Eolian_Class_Type.REGULAR and 528 if c.type == Eolian_Class_Type.REGULAR and
521 c.namespace == self._name] 529 c.namespace == self._name])
522 530
523 @property 531 @property
524 def abstracts(self): 532 def abstracts(self):
525 return [ c for c in self._unit.all_classes 533 return sorted([ c for c in self._unit.all_classes
526 if c.type == Eolian_Class_Type.ABSTRACT and 534 if c.type == Eolian_Class_Type.ABSTRACT and
527 c.namespace == self._name] 535 c.namespace == self._name])
528 536
529 @property 537 @property
530 def mixins(self): 538 def mixins(self):
531 return [ c for c in self._unit.all_classes 539 return sorted([ c for c in self._unit.all_classes
532 if c.type == Eolian_Class_Type.MIXIN and 540 if c.type == Eolian_Class_Type.MIXIN and
533 c.namespace == self._name] 541 c.namespace == self._name])
534 542
535 @property 543 @property
536 def interfaces(self): 544 def interfaces(self):
537 return [ c for c in self._unit.all_classes 545 return sorted([ c for c in self._unit.all_classes
538 if c.type == Eolian_Class_Type.INTERFACE and 546 if c.type == Eolian_Class_Type.INTERFACE and
539 c.namespace == self._name] 547 c.namespace == self._name])
540 548
541 @property 549 @property
542 def aliases(self): 550 def aliases(self):
543 return [ td for td in self._unit.typedecl_all_aliases 551 return sorted([ td for td in self._unit.typedecl_all_aliases
544 if td.namespace == self._name] 552 if td.namespace == self._name])
545 553
546 @property 554 @property
547 def structs(self): 555 def structs(self):
548 return [ td for td in self._unit.typedecl_all_structs 556 return sorted([ td for td in self._unit.typedecl_all_structs
549 if td.namespace == self._name] 557 if td.namespace == self._name])
550 558
551 @property 559 @property
552 def enums(self): 560 def enums(self):
553 return [ td for td in self._unit.typedecl_all_enums 561 return sorted([ td for td in self._unit.typedecl_all_enums
554 if td.namespace == self._name] 562 if td.namespace == self._name])
555 563
556 564
557### Eolian Classes ########################################################## 565### Eolian Classes ##########################################################