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

pull/2/head
Andrey Kamaev 13 years ago
parent 6f32fb025d
commit 4800d85011
  1. 6
      doc/conf.py
  2. 34
      doc/ocv.py

@ -231,9 +231,9 @@ latex_documents = [
('modules/refman', 'opencv2refman.tex', u'The OpenCV Reference Manual', ('modules/refman', 'opencv2refman.tex', u'The OpenCV Reference Manual',
u'', 'manual'), u'', 'manual'),
('doc/user_guide/user_guide', 'opencv_user.tex', u'The OpenCV User Guide', ('doc/user_guide/user_guide', 'opencv_user.tex', u'The OpenCV User Guide',
u'', 'manual'), u'', 'manual'),
('doc/tutorials/tutorials', 'opencv_tutorials.tex', u'The OpenCV Tutorials', ('doc/tutorials/tutorials', 'opencv_tutorials.tex', u'The OpenCV Tutorials',
u'', 'manual'), u'', 'manual'),
] ]
preamble =""" preamble ="""
@ -303,7 +303,7 @@ extlinks = {
'calib3d' : ('http://opencv.itseez.com/trunk/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#%s', None ), 'calib3d' : ('http://opencv.itseez.com/trunk/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#%s', None ),
'feature2d' : ('http://opencv.itseez.com/trunk/modules/imgproc/doc/feature_detection.html#%s', None ), 'feature2d' : ('http://opencv.itseez.com/trunk/modules/imgproc/doc/feature_detection.html#%s', None ),
'imgproc_geometric' : ('http://opencv.itseez.com/trunk/modules/imgproc/doc/geometric_transformations.html#%s', None ), 'imgproc_geometric' : ('http://opencv.itseez.com/trunk/modules/imgproc/doc/geometric_transformations.html#%s', None ),
'opencv_group' : ('http://tech.groups.yahoo.com/group/OpenCV/%s', None), 'opencv_group' : ('http://tech.groups.yahoo.com/group/OpenCV/%s', None),
'cvt_color': ('http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cvtcolor#cvtcolor%s', None), 'cvt_color': ('http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cvtcolor#cvtcolor%s', None),

@ -25,7 +25,7 @@ from sphinx.util.nodes import make_refnode
from sphinx.util.compat import Directive from sphinx.util.compat import Directive
from sphinx.util.docfields import Field, GroupedField, TypedField from sphinx.util.docfields import Field, GroupedField, TypedField
########################### Python Part ########################### ########################### Python Part ###########################
# REs for Python signatures # REs for Python signatures
py_sig_re = re.compile( py_sig_re = re.compile(
@ -292,9 +292,10 @@ class OCVPyXRefRole(XRefRole):
return title, target return title, target
########################### C/C++/Java Part ########################### ########################### 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)') _whitespace_re = re.compile(r'\s+(?u)')
_string_re = re.compile(r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'" _string_re = re.compile(r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'"
r'|"([^"\\]*(?:\\.[^"\\]*)*)")', re.S) r'|"([^"\\]*(?:\\.[^"\\]*)*)")', re.S)
@ -561,7 +562,7 @@ class ConstDefExpr(WrappingDefExpr):
def __unicode__(self): def __unicode__(self):
return (self.prefix and u'const %s' or u'%s const') % self.typename return (self.prefix and u'const %s' or u'%s const') % self.typename
class ConstTemplateDefExpr(WrappingDefExpr): class ConstTemplateDefExpr(WrappingDefExpr):
def __init__(self, typename, prefix=False): def __init__(self, typename, prefix=False):
@ -682,7 +683,7 @@ class FuncDefExpr(NamedDefExpr):
u'.'.join(x.get_id() for x in self.signature) or u'', u'.'.join(x.get_id() for x in self.signature) or u'',
self.const and u'C' or u'' self.const and u'C' or u''
) )
def __unicode__(self): def __unicode__(self):
buf = self.get_modifiers() buf = self.get_modifiers()
if self.explicit: if self.explicit:
@ -807,7 +808,7 @@ class DefinitionParser(object):
return CastOpDefExpr(type) return CastOpDefExpr(type)
def _parse_name(self): def _parse_name(self):
if not self.match(_identifier_re): if not self.match(_argument_name_re):
self.fail('expected name') self.fail('expected name')
identifier = self.matched_text identifier = self.matched_text
@ -981,7 +982,7 @@ class DefinitionParser(object):
elif paren_stack_depth == 0: elif paren_stack_depth == 0:
break break
self.pos = idx+1 self.pos = idx+1
rv = self.definition[rv_start:idx] rv = self.definition[rv_start:idx]
self.pos = idx self.pos = idx
return rv return rv
@ -1138,7 +1139,7 @@ class OCVObject(ObjectDescription):
lname = self.__class__.langname lname = self.__class__.langname
node += nodes.strong(lname + ":", lname + ":") node += nodes.strong(lname + ":", lname + ":")
node += addnodes.desc_name(" ", " ") node += addnodes.desc_name(" ", " ")
if obj.visibility != 'public': if obj.visibility != 'public':
node += addnodes.desc_annotation(obj.visibility, node += addnodes.desc_annotation(obj.visibility,
obj.visibility) obj.visibility)
@ -1298,7 +1299,12 @@ class OCVFunctionObject(OCVObject):
self.attach_type(param, arg.type) self.attach_type(param, arg.type)
param += nodes.Text(u' ') param += nodes.Text(u' ')
#param += nodes.emphasis(unicode(arg.name), unicode(arg.name)) #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: if arg.default is not None:
def_ = u'=' + unicode(arg.default) def_ = u'=' + unicode(arg.default)
#param += nodes.emphasis(def_, def_) #param += nodes.emphasis(def_, def_)
@ -1380,7 +1386,7 @@ class OCVXRefRole(XRefRole):
class OCVCFunctionObject(OCVFunctionObject): class OCVCFunctionObject(OCVFunctionObject):
langname = "C" langname = "C"
class OCVJavaFunctionObject(OCVFunctionObject): class OCVJavaFunctionObject(OCVFunctionObject):
langname = "Java" langname = "Java"
@ -1430,7 +1436,7 @@ class OCVDomain(Domain):
initial_data = { initial_data = {
'objects': {}, # fullname -> docname, objtype 'objects': {}, # fullname -> docname, objtype
} }
def __init__(self, env): def __init__(self, env):
Domain.__init__(self, env) Domain.__init__(self, env)
self.data['objects2'] = {} self.data['objects2'] = {}
@ -1496,14 +1502,14 @@ class OCVDomain(Domain):
def get_objects(self): def get_objects(self):
for refname, (docname, type, theid) in self.data['objects'].iteritems(): for refname, (docname, type, theid) in self.data['objects'].iteritems():
yield (refname, refname, type, docname, refname, 1) yield (refname, refname, type, docname, refname, 1)
def get_type_name(self, type, primary=False): def get_type_name(self, type, primary=False):
""" """
Return full name for given ObjType. Return full name for given ObjType.
""" """
if primary: if primary:
return type.lname return type.lname
return { return {
'class': _('C++ class'), 'class': _('C++ class'),
'struct': _('C/C++ struct'), 'struct': _('C/C++ struct'),
@ -1516,6 +1522,6 @@ class OCVDomain(Domain):
'type': _('C/C++ type'), 'type': _('C/C++ type'),
'namespace': _('C++ namespace'), 'namespace': _('C++ namespace'),
}.get(type.lname, _('%s %s') % (self.label, type.lname)) }.get(type.lname, _('%s %s') % (self.label, type.lname))
def setup(app): def setup(app):
app.add_domain(OCVDomain) app.add_domain(OCVDomain)

Loading…
Cancel
Save