Fixed documentation generation for function arguments having array type i.e. 'type arg[]'

This commit is contained in:
Andrey Kamaev
2012-05-29 11:41:23 +00:00
parent 6f32fb025d
commit 4800d85011
2 changed files with 23 additions and 17 deletions

View File

@@ -294,7 +294,8 @@ class OCVPyXRefRole(XRefRole):
########################### C/C++/Java Part ###########################
_identifier_re = re.compile(r'(~?\b[a-zA-Z_][a-zA-Z0-9_]*)\b')
_identifier_re = re.compile(r'(~?\b[a-zA-Z_][a-zA-Z0-9_]*\b)')
_argument_name_re = re.compile(r'(~?\b[a-zA-Z_][a-zA-Z0-9_]*\b(?:\[\d*\])?)')
_whitespace_re = re.compile(r'\s+(?u)')
_string_re = re.compile(r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'"
r'|"([^"\\]*(?:\\.[^"\\]*)*)")', re.S)
@@ -807,7 +808,7 @@ class DefinitionParser(object):
return CastOpDefExpr(type)
def _parse_name(self):
if not self.match(_identifier_re):
if not self.match(_argument_name_re):
self.fail('expected name')
identifier = self.matched_text
@@ -1298,7 +1299,12 @@ class OCVFunctionObject(OCVObject):
self.attach_type(param, arg.type)
param += nodes.Text(u' ')
#param += nodes.emphasis(unicode(arg.name), unicode(arg.name))
param += nodes.strong(unicode(arg.name), unicode(arg.name))
sbrIdx = unicode(arg.name).find("[")
if sbrIdx < 0:
param += nodes.strong(unicode(arg.name), unicode(arg.name))
else:
param += nodes.strong(unicode(arg.name)[:sbrIdx], unicode(arg.name)[:sbrIdx])
param += nodes.Text(unicode(arg.name)[sbrIdx:])
if arg.default is not None:
def_ = u'=' + unicode(arg.default)
#param += nodes.emphasis(def_, def_)