Commit 155393f9 authored by François Grisez's avatar François Grisez

[Doc generator] Generate a page for each listener.

parent e24e4e93
......@@ -315,7 +315,7 @@ class ClassPage(SphinxPage):
self.briefDoc = _class.briefDescription.translate(self.docTranslator)
self.detailedDoc = _class.detailedDescription.translate(self.docTranslator) if _class.detailedDescription is not None else None
self.enums = [EnumPart(enum, lang, langs) for enum in _class.enums]
self.properties = self._translate_properties(_class.properties)
self.properties = self._translate_properties(_class.properties) if isinstance(_class, abstractapi.Class) else []
self.methods = self._translate_methods(_class.instanceMethods)
self.classMethods = self._translate_methods(_class.classMethods)
self.selector = self._make_selector(_class)
......@@ -361,7 +361,7 @@ class ClassPage(SphinxPage):
return translatedMethods
def _translate_method(self, method):
namespace = method.find_first_ancestor_by_type(abstractapi.Class)
namespace = method.find_first_ancestor_by_type(abstractapi.Class,abstractapi.Interface)
methAttr = {
'prototype' : method.translate_as_prototype(self.lang.langTranslator, namespace=namespace),
'briefDoc' : method.briefDescription.translate(self.docTranslator),
......@@ -449,7 +449,7 @@ class DocGenerator:
filepath = page.write(directory)
indexPage.add_entry(page.filename)
cleaner.add_directory(filepath)
for class_ in self.api.namespace.classes:
for class_ in (self.api.namespace.classes + self.api.namespace.interfaces):
page = ClassPage(class_, lang, self.languages)
filepath = page.write(directory)
indexPage.add_entry(page.filename)
......
......@@ -428,27 +428,32 @@ class Class(Namespace):
self.classMethods.sort()
class Interface(DocumentableObject):
class Interface(Namespace):
def __init__(self, name):
DocumentableObject.__init__(self, name)
self.methods = []
Namespace.__init__(self, name)
self.instanceMethods = []
self.classMethods = []
self._listenedClass = None
def add_method(self, method):
self.methods.append(method)
def add_instance_methods(self, method):
self.instanceMethods.append(method)
method.parent = self
def add_class_methods(self, method):
self.classMethods.append(method)
method.parent = self
@property
def listenedClass(self):
return self._listenedClass
@listenedClass.setter
def listenedClass(self, method):
self.methods.append(method)
self.instanceMethods.append(method)
method.parent = self
def sort(self):
self.methods.sort()
self.instanceMethods.sort()
class CParser(object):
......@@ -619,7 +624,7 @@ class CParser(object):
self._fix_all_types_in_method(method)
def _fix_all_types_in_interface(self, interface):
for method in interface.methods:
for method in interface.instanceMethods:
self._fix_all_types_in_method(method)
def _fix_all_types_in_method(self, method):
......@@ -784,7 +789,7 @@ class CParser(object):
if property.name != 'user_data':
try:
method = self._parse_listener_property(property, listener, cclass.events)
listener.add_method(method)
listener.add_instance_methods(method)
except BlacklistedSymbolError as e:
logger.debug(e)
......@@ -819,6 +824,8 @@ class CParser(object):
argName.from_snake_case(arg.name)
argument = Argument(argName, self.parse_type(arg))
method.add_arguments(argument)
method.briefDescription = event.briefDoc
method.detailedDescription = event.detailedDoc
return method
......@@ -1005,7 +1012,7 @@ class CLangTranslator(CLikeLangTranslator):
raise TypeError('invalid enumerator value type: {0}'.format(value))
def translate_method_as_prototype(self, method, hideArguments=False, hideArgNames=False, hideReturnType=False, stripDeclarators=False, namespace=None):
_class = method.find_first_ancestor_by_type(Class)
_class = method.find_first_ancestor_by_type(Class,Interface)
params = []
if not hideArguments:
params.append('{const}{className} *obj'.format(
......
......@@ -460,6 +460,8 @@ class Project:
definition = node.find('./definition').text
if definition.startswith('typedef '):
definition = definition[8 :]
briefDoc = self.docparser.parse_description(node.find('./briefdescription'))
detailedDoc = self.docparser.parse_description(node.find('./detaileddescription'))
if name.endswith('Cb'):
pos = definition.find("(*")
if pos == -1:
......@@ -515,9 +517,9 @@ class Project:
if deprecatedNode is not None:
f.deprecated = True
f.briefDescription = ''.join(node.find('./briefdescription').itertext()).strip()
f.briefDoc = self.docparser.parse_description(node.find('./briefdescription'))
f.detailedDoc = self.docparser.parse_description(node.find('./detaileddescription'))
f.briefDoc = briefDoc
f.detailedDescription = self.__cleanDescription(node.find('./detaileddescription'))
f.detailedDoc = detailedDoc
return f
else:
pos = definition.rfind(" " + name)
......@@ -528,9 +530,9 @@ class Project:
if deprecatedNode is not None:
td.deprecated = True
td.briefDescription = ''.join(node.find('./briefdescription').itertext()).strip()
td.briefDoc = self.docparser.parse_description(node.find('./briefdescription'))
td.detailedDoc = self.docparser.parse_description(node.find('./detaileddescription'))
td.briefDoc = briefDoc
td.detailedDescription = self.__cleanDescription(node.find('./detaileddescription'))
td.detailedDoc = detailedDoc
return td
return None
......
......@@ -558,6 +558,7 @@ class SphinxTranslator(Translator):
if langCode == 'C':
self.domain = 'cpp'
self.classDeclarator = 'type'
self.interfaceDeclarator = self.classDeclarator
self.methodDeclarator = 'function'
self.enumDeclarator = 'enum'
self.enumeratorDeclarator = 'enumerator'
......@@ -565,6 +566,7 @@ class SphinxTranslator(Translator):
elif langCode == 'Cpp':
self.domain = 'cpp'
self.classDeclarator = 'class'
self.interfaceDeclarator = self.classDeclarator
self.methodDeclarator = 'function'
self.enumDeclarator = 'enum'
self.enumeratorDeclarator = 'enumerator'
......@@ -573,17 +575,20 @@ class SphinxTranslator(Translator):
elif langCode == 'CSharp':
self.domain = 'csharp'
self.classDeclarator = 'class'
self.interfaceDeclarator = self.classDeclarator
self.methodDeclarator = 'method'
self.enumDeclarator = 'enum'
self.enumeratorDeclarator = 'value'
self.namespaceDeclarator = 'namespace'
self.classReferencer = 'type'
self.interfaceReferencer = self.classReferencer
self.enumReferencer = 'type'
self.enumeratorReferencer = 'enum'
self.methodReferencer = 'meth'
elif langCode == 'Java':
self.domain = 'java'
self.classDeclarator = 'type'
self.interfaceDeclarator = self.classDeclarator
self.methodDeclarator = 'method'
self.enumDeclarator = 'type'
self.enumeratorDeclarator = 'field'
......
......@@ -104,7 +104,7 @@ class CppTranslator(object):
classDict['listenerClassName'] = _class.listenerInterface.name.translate(self.nameTranslator)
classDict['cListenerName'] = _class.listenerInterface.name.to_c()
classDict['cppListenerName'] = _class.listenerInterface.name.translate(self.nameTranslator)
for method in _class.listenerInterface.methods:
for method in _class.listenerInterface.instanceMethods:
classDict['wrapperCbs'].append(self._generate_wrapper_callback(_class, method))
if ismonolistenable:
......@@ -173,7 +173,7 @@ class CppTranslator(object):
'isListener' : True,
'methods' : []
}
for method in interface.methods:
for method in interface.instanceMethods:
methodDict = self.translate_method(method, genImpl=False)
intDict['methods'].append(methodDict)
......@@ -375,7 +375,7 @@ class ClassHeader(object):
if type(_class) is AbsApi.Class:
methods = _class.classMethods + _class.instanceMethods
else:
methods = _class.methods
methods = _class.instanceMethods
for method in methods:
self._populate_needed_includes_from_type(method.returnType)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment