From 94b6ad8448c5fe157c5b77435eb7c3873d778920 Mon Sep 17 00:00:00 2001 From: Dave Andreoli Date: Wed, 24 Jan 2018 22:26:29 +0100 Subject: [PATCH] pyolian: improve the doc generation --- src/scripts/gendoc/doc_start.template | 109 +++++++++++++++----------- src/scripts/gendoc/gendoc.py | 28 ++++++- src/scripts/pyolian/eolian.py | 19 ++++- 3 files changed, 109 insertions(+), 47 deletions(-) diff --git a/src/scripts/gendoc/doc_start.template b/src/scripts/gendoc/doc_start.template index 640f805d9d..aeeed38fd3 100644 --- a/src/scripts/gendoc/doc_start.template +++ b/src/scripts/gendoc/doc_start.template @@ -2,51 +2,70 @@ ~~Title: EFL Reference~~ {{page>:develop:api-include:reference:general&nouser&nolink&nodate}} - - -===== ${ns.name}$ ===== +====== Python-EFL documentation preview ====== +This is just a work in progress for the future development of the +Python-EFL Unified API. - - -^ Classes ^^ - -| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | - -#! - - -^ Interfaces ^^ - -| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | - -#! - - -^ Mixins ^^ - -| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | - -#! - - -^ Aliases ^^ - -| ${TYPEDECL_LINK}$ | ${BEST_SUMMARY(obj=typedecl)}$ | - -#! - - -^ Structures ^^ - -| ${TYPEDECL_LINK}$ | ${BEST_SUMMARY(obj=typedecl)}$ | - -#! - - -^ Enumerations ^^ - -| ${TYPEDECL_LINK}$ | ${BEST_SUMMARY(obj=typedecl)}$ | - +Pratically there is nothing python related currently in this documentation, +so it can be considered valid for all languages. + + +^** Some numbers just for information **^^ + +| ${label}$ | **${val}$** | + + + + +===== ${ns.name}$ (namespace) ===== + + + +^ Regular Classes ^^ + +| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | + +#! + + +^ Abstract Classes ^^ + +| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | + +#! + + +^ Mixins ^^ + +| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | + +#! + + +^ Interfaces ^^ + +| ${CLS_LINK}$ | ${BEST_SUMMARY(obj=cls)}$ | + +#! + + +^ Aliases ^^ + +| ${TYPEDECL_LINK}$ | ${BEST_SUMMARY(obj=typedecl)}$ | + +#! + + +^ Structures ^^ + +| ${TYPEDECL_LINK}$ | ${BEST_SUMMARY(obj=typedecl)}$ | + +#! + + +^ Enumerations ^^ + +| ${TYPEDECL_LINK}$ | ${BEST_SUMMARY(obj=typedecl)}$ | + - diff --git a/src/scripts/gendoc/gendoc.py b/src/scripts/gendoc/gendoc.py index 394c641f44..d3286229c6 100755 --- a/src/scripts/gendoc/gendoc.py +++ b/src/scripts/gendoc/gendoc.py @@ -79,8 +79,34 @@ def page_path_for_object(obj): # render the main start.txt page if args.step in ('start', None): t = Template('doc_start.template') + + nspaces = [ ns for ns in eolian_db.all_namespaces + if ns.name.startswith(args.namespace) ] + + tot_classes = tot_regulars = tot_abstracts = tot_mixins = tot_ifaces = 0 + for ns in nspaces: + for cls in ns.classes: + tot_classes += 1 + if cls.type == eolian.Eolian_Class_Type.REGULAR: + tot_regulars += 1 + elif cls.type == eolian.Eolian_Class_Type.ABSTRACT: + tot_abstracts += 1 + elif cls.type == eolian.Eolian_Class_Type.MIXIN: + tot_mixins += 1 + elif cls.type == eolian.Eolian_Class_Type.INTERFACE: + tot_ifaces += 1 + totals = [ + ('Namespaces', len(nspaces)), + ('ALL Classes', tot_classes), + ('Regular classes', tot_regulars), + ('Abstract classes', tot_abstracts), + ('Mixins', tot_mixins), + ('Interfaces', tot_ifaces), + ] + output_file = os.path.join(args.root_path,'data','pages','develop','api','start.txt') - t.render(output_file, args.verbose, nspaces=eolian_db.all_namespaces) + t.render(output_file, args.verbose, nspaces=nspaces, totals=totals) + # render a page for each Class if args.step in ('classes', None): diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index 291865bdf4..6e3b52b3ec 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py @@ -318,6 +318,13 @@ class EolianBaseObject(object): return self.name == other return False + def __gt__(self, other): + if isinstance(other, EolianBaseObject): + if hasattr(self, 'full_name'): + return self.full_name > other.full_name + elif hasattr(self, 'name'): + return self.name > other.name + def __hash__(self): return self._obj.value @@ -479,7 +486,11 @@ class Namespace(object): return "".format(self) def __eq__(self, other): - return self.name == other.name + if isinstance(other, Namespace): + return self.name == other.name + if isinstance(other, str): + return self.name == other + raise TypeError('Namespace can only compare with Namespace or str') def __lt__(self, other): return self.name < other.name @@ -509,6 +520,12 @@ class Namespace(object): if c.type == Eolian_Class_Type.REGULAR and c.namespace == self._name] + @property + def abstracts(self): + return [ c for c in self._unit.all_classes + if c.type == Eolian_Class_Type.ABSTRACT and + c.namespace == self._name] + @property def mixins(self): return [ c for c in self._unit.all_classes