Commit f0e0f1a9 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Document enums in the Python wrapper.

parent 6b88923d
......@@ -224,7 +224,7 @@ class MethodDefinition:
if argument_type.fmt_str == 'O':
fmt += ' [' + argument_type.cfmt_str + ']'
args.append(arg_name)
args=', '.join(args)
args = ', '.join(args)
if args != '':
args = ', ' + args
return "\tpylinphone_trace(1, \"[PYLINPHONE] >>> %s({fmt})\", __FUNCTION__{args});\n".format(fmt=fmt, args=args)
......@@ -711,7 +711,8 @@ class LinphoneModule(object):
continue
e = {}
e['enum_name'] = strip_leading_linphone(xml_enum.get('name'))
e['enum_doc'] = self.__format_doc(xml_enum.find('briefdescription'), xml_enum.find('detaileddescription'))
e['enum_doc'] = self.__format_doc_content(xml_enum.find('briefdescription'), xml_enum.find('detaileddescription'))
e['enum_doc'] += "\n\nValues:\n"
e['enum_values'] = []
xml_enum_values = xml_enum.findall("./values/value")
for xml_enum_value in xml_enum_values:
......@@ -720,7 +721,10 @@ class LinphoneModule(object):
v = {}
v['enum_value_cname'] = xml_enum_value.get('name')
v['enum_value_name'] = strip_leading_linphone(v['enum_value_cname'])
v['enum_value_doc'] = self.__format_doc(xml_enum_value.find('briefdescription'), xml_enum_value.find('detaileddescription'))
e['enum_doc'] += '\t' + v['enum_value_name'] + ': ' + v['enum_value_doc'] + '\n'
e['enum_values'].append(v)
e['enum_doc'] = self.__replace_doc_special_chars(e['enum_doc'])
self.enums.append(e)
self.enum_names.append(e['enum_name'])
self.events = []
......@@ -898,7 +902,7 @@ class LinphoneModule(object):
desc += '\n'
return desc
def __format_doc(self, brief_description, detailed_description):
def __format_doc_content(self, brief_description, detailed_description):
doc = ''
if brief_description is None:
brief_description = ''
......@@ -908,12 +912,19 @@ class LinphoneModule(object):
desc = ''
for node in list(detailed_description):
desc += self.__format_doc_node(node) + '\n'
detailed_description = desc.strip().replace('\n', '\\n')
detailed_description = desc.strip()
brief_description = brief_description.strip()
doc += brief_description
if detailed_description != '':
if doc != '':
doc += '\\n\\n'
doc+= detailed_description
doc = '\"' + doc + '\"'
doc += '\n\n'
doc += detailed_description
return doc
def __replace_doc_special_chars(self, doc):
return doc.replace('"', '').encode('string-escape')
def __format_doc(self, brief_description, detailed_description):
doc = self.__format_doc_content(brief_description, detailed_description)
doc = self.__replace_doc_special_chars(doc)
return doc
......@@ -163,7 +163,7 @@ static PyTypeObject pylinphone_{{class_name}}Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
{{{class_doc}}}, /* tp_doc */
"{{{class_doc}}}", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
......@@ -220,7 +220,7 @@ static PyObject * pylinphone_{{enum_name}}_module_method_string(PyObject *self,
}
static PyMethodDef pylinphone_{{enum_name}}_ModuleMethods[] = {
{ "string", pylinphone_{{enum_name}}_module_method_string, METH_VARARGS, "" },
{ "string", pylinphone_{{enum_name}}_module_method_string, METH_VARARGS, "Get a string representation of a linphone.{{enum_name}} value." },
/* Sentinel */
{ NULL, NULL, 0, NULL }
};
......@@ -241,7 +241,7 @@ PyMODINIT_FUNC initlinphone(void) {
if (m == NULL) return;
{{#enums}}
menum = Py_InitModule3("{{enum_name}}", pylinphone_{{enum_name}}_ModuleMethods, {{{enum_doc}}});
menum = Py_InitModule3("{{enum_name}}", pylinphone_{{enum_name}}_ModuleMethods, "{{{enum_doc}}}");
if (menum == NULL) return;
if (PyModule_AddObject(m, "{{enum_name}}", menum) < 0) return;
{{#enum_values}}
......
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