summaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2019-10-07 19:38:50 +0200
committerDave Andreoli <dave@gurumeditation.it>2019-10-07 19:39:07 +0200
commit3cdb87990aa92af0a395d70d04d608f49f76eb7f (patch)
treec39d24de5d852fbc4423a022dfb9fb17a0fa1cc7 /src/scripts
parent4f947925a1d51402d73aa252913eb6a43c0e7dce (diff)
Pyolian gendoc: add ability to generate only the stable API
gendoc.py --exclude-beta generate the docs excluding all the classes/types/etc in beta state, a bit hackish but do the job. There are some broken links around that refer to objects in beta state that are (correctly) not generated, nothing we can do to fix this.
Diffstat (limited to 'src/scripts')
-rwxr-xr-xsrc/scripts/gendoc/gendoc.py71
-rw-r--r--src/scripts/pyolian/eolian.py4
2 files changed, 64 insertions, 11 deletions
diff --git a/src/scripts/gendoc/gendoc.py b/src/scripts/gendoc/gendoc.py
index bee5161f0b..b1108b71fd 100755
--- a/src/scripts/gendoc/gendoc.py
+++ b/src/scripts/gendoc/gendoc.py
@@ -35,6 +35,8 @@ parser.add_argument('--root-path', '-r', metavar='FOLDER', default='dokuwiki',
35 'default to: "./dokuwiki"') 35 'default to: "./dokuwiki"')
36parser.add_argument('--verbose', '-v', action='store_true', 36parser.add_argument('--verbose', '-v', action='store_true',
37 help='print a line for each rendered file') 37 help='print a line for each rendered file')
38parser.add_argument('--exclude-beta', '-e', action='store_true',
39 help='do not generate docs for class in beta state')
38parser.add_argument('--namespace', '-n', metavar='ROOT', default='Efl', 40parser.add_argument('--namespace', '-n', metavar='ROOT', default='Efl',
39 help='root namespace of the docs. (default to "Efl")') 41 help='root namespace of the docs. (default to "Efl")')
40_choices = ['start', 'classes', 'enums', 'structs', 'aliases'] 42_choices = ['start', 'classes', 'enums', 'structs', 'aliases']
@@ -78,9 +80,52 @@ def page_path_for_object(obj):
78 return os.path.join(args.root_path, *path, output_filename) 80 return os.path.join(args.root_path, *path, output_filename)
79 81
80 82
83class BetaNamespaceWrapper(eolian.Namespace):
84 """ A Namespace wrapper that hide objects marked as beta to the template """
85 def __init__(self, eolian_ns):
86 super(BetaNamespaceWrapper, self).__init__(eolian_ns.unit, eolian_ns.name)
87 self._ns = eolian_ns
88
89 @property
90 def sub_namespaces(self):
91 return [BetaNamespaceWrapper(ns) for ns in self._ns.sub_namespaces]
92
93 @property
94 def classes(self):
95 return [c for c in self._ns.classes if not (args.exclude_beta and c.is_beta)]
96
97 @property
98 def regulars(self):
99 return [c for c in self._ns.regulars if not (args.exclude_beta and c.is_beta)]
100
101 @property
102 def abstracts(self):
103 return [c for c in self._ns.abstracts if not (args.exclude_beta and c.is_beta)]
104
105 @property
106 def mixins(self):
107 return [c for c in self._ns.mixins if not (args.exclude_beta and c.is_beta)]
108
109 @property
110 def interfaces(self):
111 return [c for c in self._ns.interfaces if not (args.exclude_beta and c.is_beta)]
112
113 @property
114 def aliases(self):
115 return [c for c in self._ns.aliases if not (args.exclude_beta and c.is_beta)]
116
117 @property
118 def structs(self):
119 return [c for c in self._ns.structs if not (args.exclude_beta and c.is_beta)]
120
121 @property
122 def enums(self):
123 return [c for c in self._ns.enums if not (args.exclude_beta and c.is_beta)]
124
125
81# render a (temporary) page for analizying the namespaces hierarchy 126# render a (temporary) page for analizying the namespaces hierarchy
82t = Template('namespaces.template') 127t = Template('namespaces.template')
83nspaces = [ns for ns in eolian_db.all_namespaces 128nspaces = [BetaNamespaceWrapper(ns) for ns in eolian_db.all_namespaces
84 if ns.name.startswith(args.namespace)] 129 if ns.name.startswith(args.namespace)]
85 130
86tot_classes = tot_regulars = tot_abstracts = tot_mixins = tot_ifaces = 0 131tot_classes = tot_regulars = tot_abstracts = tot_mixins = tot_ifaces = 0
@@ -113,7 +158,7 @@ totals = [
113 ('Aliases', tot_aliases), 158 ('Aliases', tot_aliases),
114] 159]
115 160
116root_ns = eolian_db.namespace_get_by_name(args.namespace) 161root_ns = BetaNamespaceWrapper(eolian_db.namespace_get_by_name(args.namespace))
117 162
118output_file = os.path.join(args.root_path, 'data', 'pages', 'develop', 'api', 'namespaces.txt') 163output_file = os.path.join(args.root_path, 'data', 'pages', 'develop', 'api', 'namespaces.txt')
119t.render(output_file, args.verbose, root_ns=root_ns, totals=totals) 164t.render(output_file, args.verbose, root_ns=root_ns, totals=totals)
@@ -123,7 +168,7 @@ t.render(output_file, args.verbose, root_ns=root_ns, totals=totals)
123if args.step in ('start', None): 168if args.step in ('start', None):
124 t = Template('doc_start.template') 169 t = Template('doc_start.template')
125 170
126 nspaces = [ns for ns in eolian_db.all_namespaces 171 nspaces = [BetaNamespaceWrapper(ns) for ns in eolian_db.all_namespaces
127 if ns.name.startswith(args.namespace)] 172 if ns.name.startswith(args.namespace)]
128 173
129 output_file = os.path.join(args.root_path, 'data', 'pages', 'develop', 'api', 'start.txt') 174 output_file = os.path.join(args.root_path, 'data', 'pages', 'develop', 'api', 'start.txt')
@@ -135,29 +180,33 @@ if args.step in ('classes', None):
135 t = Template('doc_class.template') 180 t = Template('doc_class.template')
136 for cls in eolian_db.classes: 181 for cls in eolian_db.classes:
137 if cls.name.startswith(args.namespace): 182 if cls.name.startswith(args.namespace):
138 output_file = page_path_for_object(cls) 183 if not (args.exclude_beta and cls.is_beta):
139 t.render(output_file, args.verbose, cls=cls.name) 184 output_file = page_path_for_object(cls)
185 t.render(output_file, args.verbose, cls=cls.name)
140 186
141# render a page for each Enum 187# render a page for each Enum
142if args.step in ('enums', None): 188if args.step in ('enums', None):
143 t = Template('doc_enum.template') 189 t = Template('doc_enum.template')
144 for enum in eolian_db.enums: 190 for enum in eolian_db.enums:
145 if enum.name.startswith(args.namespace): 191 if enum.name.startswith(args.namespace):
146 output_file = page_path_for_object(enum) 192 if not (args.exclude_beta and enum.is_beta):
147 t.render(output_file, args.verbose, enum=enum.name) 193 output_file = page_path_for_object(enum)
194 t.render(output_file, args.verbose, enum=enum.name)
148 195
149# render a page for each Struct 196# render a page for each Struct
150if args.step in ('structs', None): 197if args.step in ('structs', None):
151 t = Template('doc_struct.template') 198 t = Template('doc_struct.template')
152 for struct in eolian_db.structs: 199 for struct in eolian_db.structs:
153 if struct.name.startswith(args.namespace): 200 if struct.name.startswith(args.namespace):
154 output_file = page_path_for_object(struct) 201 if not (args.exclude_beta and struct.is_beta):
155 t.render(output_file, args.verbose, struct=struct.name) 202 output_file = page_path_for_object(struct)
203 t.render(output_file, args.verbose, struct=struct.name)
156 204
157# render a page for each Alias 205# render a page for each Alias
158if args.step in ('aliases', None): 206if args.step in ('aliases', None):
159 t = Template('doc_alias.template') 207 t = Template('doc_alias.template')
160 for alias in eolian_db.aliases: 208 for alias in eolian_db.aliases:
161 if alias.name.startswith(args.namespace): 209 if alias.name.startswith(args.namespace):
162 output_file = page_path_for_object(alias) 210 if not (args.exclude_beta and alias.is_beta):
163 t.render(output_file, args.verbose, alias=alias.name) 211 output_file = page_path_for_object(alias)
212 t.render(output_file, args.verbose, alias=alias.name)
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 50db1e6f3c..58c3105e03 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -532,6 +532,10 @@ class Namespace(object):
532 return hash(self._name) 532 return hash(self._name)
533 533
534 @property 534 @property
535 def unit(self):
536 return self._unit
537
538 @property
535 def name(self): 539 def name(self):
536 return self._name 540 return self._name
537 541