Fixed search in html documentation (ticket #1232)

This commit is contained in:
Andrey Kamaev 2011-08-12 07:23:54 +00:00
parent ea971df8bf
commit 67a98bfd24
2 changed files with 38 additions and 8 deletions

View File

@ -358,4 +358,8 @@ margin-top: 0px;
.toctableopencv colgroup col:nth-child(2) .toctableopencv colgroup col:nth-child(2)
{ {
width: 100% !important; width: 100% !important;
} }
div.body ul.search li {
text-align: left;
}

View File

@ -215,7 +215,7 @@ class OCVPyObject(ObjectDescription):
signode['ids'].append(fullname) signode['ids'].append(fullname)
signode['first'] = (not self.names) signode['first'] = (not self.names)
self.state.document.note_explicit_target(signode) self.state.document.note_explicit_target(signode)
objects = self.env.domaindata['py']['objects'] objects = self.env.domaindata['ocv']['objects']
if fullname in objects: if fullname in objects:
self.env.warn( self.env.warn(
self.env.docname, self.env.docname,
@ -224,7 +224,7 @@ class OCVPyObject(ObjectDescription):
self.env.doc2path(objects[fullname][0]) + self.env.doc2path(objects[fullname][0]) +
', use :noindex: for one of them', ', use :noindex: for one of them',
self.lineno) self.lineno)
objects[fullname] = (self.env.docname, self.objtype) objects.setdefault(fullname, (self.env.docname, self.objtype, name_cls[0]))
indextext = self.get_index_text(modname, name_cls) indextext = self.get_index_text(modname, name_cls)
if indextext: if indextext:
@ -669,7 +669,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:
@ -1133,7 +1133,11 @@ class OCVObject(ObjectDescription):
node += nodes.Text(' ') node += nodes.Text(' ')
def add_target_and_index(self, sigobj, sig, signode): def add_target_and_index(self, sigobj, sig, signode):
theid = sigobj.get_id() theid = sig#obj.get_id()
theid = re.sub(r" +", " ", theid)
theid = re.sub(r"=[^,()]+\([^)]*?\)[^,)]*(,|\))", "\\1", theid)
theid = re.sub(r"=[^,)]+(,|\))", "\\1", theid)
theid = theid.replace("( ", "(").replace(" )", ")")
name = unicode(sigobj.name) name = unicode(sigobj.name)
if theid not in self.state.document.ids: if theid not in self.state.document.ids:
signode['names'].append(theid) signode['names'].append(theid)
@ -1141,7 +1145,9 @@ class OCVObject(ObjectDescription):
signode['first'] = (not self.names) signode['first'] = (not self.names)
self.state.document.note_explicit_target(signode) self.state.document.note_explicit_target(signode)
self.env.domaindata['ocv']['objects'].setdefault(name, #self.env.domaindata['ocv']['objects'].setdefault(name,
#(self.env.docname, self.objtype, theid))
self.env.domaindata['ocv']['objects'].setdefault(theid,
(self.env.docname, self.objtype, theid)) (self.env.docname, self.objtype, theid))
indextext = self.get_index_text(name) indextext = self.get_index_text(name)
@ -1437,7 +1443,7 @@ class OCVDomain(Domain):
raise DefinitionError('') raise DefinitionError('')
except DefinitionError: except DefinitionError:
refdoc = node.get('refdoc', fromdocname) refdoc = node.get('refdoc', fromdocname)
env.warn(refdoc, 'unparseable C++ definition: %r' % target, env.warn(refdoc, 'unparseable1 C++ definition: %r' % target,
node.line) node.line)
return None return None
@ -1458,6 +1464,26 @@ 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):
"""
Return full name for given ObjType.
"""
if primary:
return type.lname
return {
'class': _('C++ class'),
'struct': _('C/C++ struct'),
'function': _('C++ function'),
'cfunction': _('C function'),
'jfunction': _('Java method'),
'pyfunction': _('Python function'),
'pyoldfunction': _('Legacy Python function'),
'member': _('C++ member'),
'type': _('C/C++ type'),
'namespace': _('C++ namespace'),
}.get(type.lname, _('%s %s') % (self.label, type.lname))
def setup(app): def setup(app):
app.add_domain(OCVDomain) app.add_domain(OCVDomain)