From 67a98bfd240ef6aea1e915ed2ccc269417217c51 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 12 Aug 2011 07:23:54 +0000 Subject: [PATCH] Fixed search in html documentation (ticket #1232) --- doc/_themes/blue/static/default.css_t | 6 +++++- doc/ocv.py | 40 +++++++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/doc/_themes/blue/static/default.css_t b/doc/_themes/blue/static/default.css_t index 3a32c16..56317cc 100644 --- a/doc/_themes/blue/static/default.css_t +++ b/doc/_themes/blue/static/default.css_t @@ -358,4 +358,8 @@ margin-top: 0px; .toctableopencv colgroup col:nth-child(2) { width: 100% !important; - } \ No newline at end of file + } + +div.body ul.search li { + text-align: left; +} diff --git a/doc/ocv.py b/doc/ocv.py index d0c3885..a2f0266 100644 --- a/doc/ocv.py +++ b/doc/ocv.py @@ -215,7 +215,7 @@ class OCVPyObject(ObjectDescription): signode['ids'].append(fullname) signode['first'] = (not self.names) self.state.document.note_explicit_target(signode) - objects = self.env.domaindata['py']['objects'] + objects = self.env.domaindata['ocv']['objects'] if fullname in objects: self.env.warn( self.env.docname, @@ -224,7 +224,7 @@ class OCVPyObject(ObjectDescription): self.env.doc2path(objects[fullname][0]) + ', use :noindex: for one of them', 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) if indextext: @@ -669,7 +669,7 @@ class FuncDefExpr(NamedDefExpr): u'.'.join(x.get_id() for x in self.signature) or u'', self.const and u'C' or u'' ) - + def __unicode__(self): buf = self.get_modifiers() if self.explicit: @@ -1133,7 +1133,11 @@ class OCVObject(ObjectDescription): node += nodes.Text(' ') 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) if theid not in self.state.document.ids: signode['names'].append(theid) @@ -1141,7 +1145,9 @@ class OCVObject(ObjectDescription): signode['first'] = (not self.names) 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)) indextext = self.get_index_text(name) @@ -1437,7 +1443,7 @@ class OCVDomain(Domain): raise DefinitionError('') except DefinitionError: refdoc = node.get('refdoc', fromdocname) - env.warn(refdoc, 'unparseable C++ definition: %r' % target, + env.warn(refdoc, 'unparseable1 C++ definition: %r' % target, node.line) return None @@ -1458,6 +1464,26 @@ class OCVDomain(Domain): def get_objects(self): for refname, (docname, type, theid) in self.data['objects'].iteritems(): 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): app.add_domain(OCVDomain) -- 2.7.4