mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 00:29:21 +00:00
Add methods documentation in the Python wrapper.
This commit is contained in:
parent
0cc70b04ab
commit
51c72605fb
2 changed files with 27 additions and 3 deletions
|
|
@ -851,8 +851,10 @@ class LinphoneModule(object):
|
|||
try:
|
||||
for m in c['class_type_methods']:
|
||||
m['method_body'] = MethodDefinition(self, c, m['method_xml_node']).format()
|
||||
m['method_doc'] = self.__format_method_doc(m['method_xml_node'])
|
||||
for m in c['class_instance_methods']:
|
||||
m['method_body'] = MethodDefinition(self, c, m['method_xml_node']).format()
|
||||
m['method_doc'] = self.__format_method_doc(m['method_xml_node'])
|
||||
except Exception, e:
|
||||
e.args += (c['class_name'], m['method_name'])
|
||||
raise
|
||||
|
|
@ -928,3 +930,26 @@ class LinphoneModule(object):
|
|||
doc = self.__format_doc_content(brief_description, detailed_description)
|
||||
doc = self.__replace_doc_special_chars(doc)
|
||||
return doc
|
||||
|
||||
def __format_method_doc(self, xml_node):
|
||||
doc = self.__format_doc_content(xml_node.find('briefdescription'), xml_node.find('detaileddescription'))
|
||||
xml_method_return = xml_node.find('./return')
|
||||
xml_method_args = xml_node.findall('./arguments/argument')
|
||||
method_type = xml_node.tag
|
||||
if method_type != 'classmethod' and len(xml_method_args) > 0:
|
||||
xml_method_args = xml_method_args[1:]
|
||||
if len(xml_method_args) > 0:
|
||||
doc += "\n\nArguments:"
|
||||
for xml_method_arg in xml_method_args:
|
||||
arg_name = xml_method_arg.get('name')
|
||||
arg_doc = self.__format_doc_content(None, xml_method_arg.find('description'))
|
||||
doc += '\n\t' + arg_name
|
||||
if arg_doc != '':
|
||||
doc += ': ' + arg_doc
|
||||
if xml_method_return is not None:
|
||||
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
|
||||
doc = self.__replace_doc_special_chars(doc)
|
||||
return doc
|
||||
|
|
|
|||
|
|
@ -101,20 +101,19 @@ static PyObject * pylinphone_{{class_name}}_instance_method_{{method_name}}(PyOb
|
|||
{{/class_instance_methods}}
|
||||
|
||||
static PyMethodDef pylinphone_{{class_name}}_instance_methods[] = {
|
||||
// TODO: Handle doc
|
||||
/* Class methods */
|
||||
{{#class_type_hand_written_methods}}
|
||||
{ "{{method_name}}", pylinphone_{{class_name}}_class_method_{{method_name}}, METH_VARARGS | METH_CLASS, "" },
|
||||
{{/class_type_hand_written_methods}}
|
||||
{{#class_type_methods}}
|
||||
{ "{{method_name}}", pylinphone_{{class_name}}_class_method_{{method_name}}, METH_VARARGS | METH_CLASS, "" },
|
||||
{ "{{method_name}}", pylinphone_{{class_name}}_class_method_{{method_name}}, METH_VARARGS | METH_CLASS, "{{{method_doc}}}" },
|
||||
{{/class_type_methods}}
|
||||
/* Instance methods */
|
||||
{{#class_instance_hand_written_methods}}
|
||||
{ "{{method_name}}", pylinphone_{{class_name}}_instance_method_{{method_name}}, METH_VARARGS, "" },
|
||||
{{/class_instance_hand_written_methods}}
|
||||
{{#class_instance_methods}}
|
||||
{ "{{method_name}}", pylinphone_{{class_name}}_instance_method_{{method_name}}, METH_VARARGS, "" },
|
||||
{ "{{method_name}}", pylinphone_{{class_name}}_instance_method_{{method_name}}, METH_VARARGS, "{{{method_doc}}}" },
|
||||
{{/class_instance_methods}}
|
||||
/* Sentinel */
|
||||
{ NULL, NULL, 0, NULL }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue