From d5332aa80a66711e4c97fcf2430c0c3a1abd37b9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 13 Aug 2014 14:11:27 +0200 Subject: [PATCH] Document arguments type in the Python wrapper. --- .../handwritten_definitions.mustache | 4 +-- tools/python/apixml2python/linphone.py | 36 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index 73baddea6..6b6a4eecf 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -284,8 +284,8 @@ static int pylinphone_VideoSize_init(PyObject *self, PyObject *args, PyObject *k } static PyMemberDef pylinphone_VideoSize_members[] = { - { "width", T_INT, offsetof(pylinphone_VideoSizeObject, vs) + offsetof(MSVideoSize, width), 0, "The width of the video" }, - { "height", T_INT, offsetof(pylinphone_VideoSizeObject, vs) + offsetof(MSVideoSize, height), 0, "The height of the video" }, + { "width", T_INT, offsetof(pylinphone_VideoSizeObject, vs) + offsetof(MSVideoSize, width), 0, "[int] The width of the video" }, + { "height", T_INT, offsetof(pylinphone_VideoSizeObject, vs) + offsetof(MSVideoSize, height), 0, "[int] The height of the video" }, { NULL } /* Sentinel */ }; diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 7d3fe6280..4a6fc98fd 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -151,7 +151,10 @@ class ArgumentType: self.fmt_str = 'i' self.cfmt_str = '%d' elif '*' in splitted_type: + self.type_str = 'linphone.' + strip_leading_linphone(self.basic_type) self.use_native_pointer = True + else: + self.type_str = 'linphone.' + strip_leading_linphone(self.basic_type) class MethodDefinition: @@ -849,11 +852,11 @@ class LinphoneModule(object): p['property_doc'] = '' if p.has_key('setter_xml_node'): p['setter_body'] = SetterMethodDefinition(self, c, p['setter_xml_node']).format() - p['property_doc'] = self.__format_doc(p['setter_xml_node'].find('briefdescription'), p['setter_xml_node'].find('detaileddescription')) + p['property_doc'] = self.__format_setter_doc(p['setter_xml_node']) if p.has_key('getter_xml_node'): p['getter_body'] = GetterMethodDefinition(self, c, p['getter_xml_node']).format() if p['property_doc'] == '': - p['property_doc'] = self.__format_doc(p['getter_xml_node'].find('briefdescription'), p['getter_xml_node'].find('detaileddescription')) + p['property_doc'] = self.__format_getter_doc(p['getter_xml_node']) except Exception, e: e.args += (c['class_name'], p['property_name']) raise @@ -932,14 +935,39 @@ class LinphoneModule(object): doc += "\n\nArguments:" for xml_method_arg in xml_method_args: arg_name = xml_method_arg.get('name') + arg_type = xml_method_arg.get('type') + arg_complete_type = xml_method_arg.get('completetype') + argument_type = ArgumentType(arg_type, arg_complete_type, self) arg_doc = self.__format_doc_content(None, xml_method_arg.find('description')) - doc += '\n\t' + arg_name + doc += '\n\t' + arg_name + ' [' + argument_type.type_str + ']' if arg_doc != '': doc += ': ' + arg_doc if xml_method_return is not None: + return_type = xml_method_return.get('type') return_complete_type = xml_method_return.get('completetype') if return_complete_type != 'void': return_doc = self.__format_doc_content(None, xml_method_return.find('description')) - doc += '\n\nReturns:\n\t' + return_doc + return_argument_type = ArgumentType(return_type, return_complete_type, self) + doc += '\n\nReturns:\n\t[' + return_argument_type.type_str + '] ' + return_doc + doc = self.__replace_doc_special_chars(doc) + return doc + + def __format_setter_doc(self, xml_node): + xml_method_arg = xml_node.findall('./arguments/argument')[1] + arg_type = xml_method_arg.get('type') + arg_complete_type = xml_method_arg.get('completetype') + argument_type = ArgumentType(arg_type, arg_complete_type, self) + doc = self.__format_doc_content(xml_node.find('briefdescription'), xml_node.find('detaileddescription')) + doc = '[' + argument_type.type_str + '] ' + doc + doc = self.__replace_doc_special_chars(doc) + return doc + + def __format_getter_doc(self, xml_node): + xml_method_return = xml_node.find('./return') + return_type = xml_method_return.get('type') + return_complete_type = xml_method_return.get('completetype') + return_argument_type = ArgumentType(return_type, return_complete_type, self) + doc = self.__format_doc_content(xml_node.find('briefdescription'), xml_node.find('detaileddescription')) + doc = '[' + return_argument_type.type_str + '] ' + doc doc = self.__replace_doc_special_chars(doc) return doc