mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #727: Fix the links to search results with custom object types.
This commit is contained in:
parent
db87ed440c
commit
01f45a12c7
2
CHANGES
2
CHANGES
@ -1,6 +1,8 @@
|
||||
Release 1.0.8 (Sep 23, 2011)
|
||||
============================
|
||||
|
||||
* #727: Fix the links to search results with custom object types.
|
||||
|
||||
* #648: Fix line numbers reported in warnings about undefined
|
||||
references.
|
||||
|
||||
|
@ -121,7 +121,7 @@ class IndexBuilder(object):
|
||||
self._mapping = {}
|
||||
# objtype -> index
|
||||
self._objtypes = {}
|
||||
# objtype index -> objname (localized)
|
||||
# objtype index -> (domain, type, objname (localized))
|
||||
self._objnames = {}
|
||||
|
||||
def load(self, stream, format):
|
||||
@ -160,21 +160,27 @@ class IndexBuilder(object):
|
||||
continue
|
||||
if prio < 0:
|
||||
continue
|
||||
# XXX splitting at dot is kind of Python specific
|
||||
prefix, name = rpartition(fullname, '.')
|
||||
pdict = rv.setdefault(prefix, {})
|
||||
try:
|
||||
i = otypes[domainname, type]
|
||||
typeindex = otypes[domainname, type]
|
||||
except KeyError:
|
||||
i = len(otypes)
|
||||
otypes[domainname, type] = i
|
||||
typeindex = len(otypes)
|
||||
otypes[domainname, type] = typeindex
|
||||
otype = domain.object_types.get(type)
|
||||
if otype:
|
||||
# use unicode() to fire translation proxies
|
||||
onames[i] = unicode(domain.get_type_name(otype))
|
||||
onames[typeindex] = (domainname, type,
|
||||
unicode(domain.get_type_name(otype)))
|
||||
else:
|
||||
onames[i] = type
|
||||
pdict[name] = (fn2index[docname], i, prio)
|
||||
onames[typeindex] = (domainname, type, type)
|
||||
if anchor == fullname:
|
||||
shortanchor = ''
|
||||
elif anchor == type + '-' + fullname:
|
||||
shortanchor = '-'
|
||||
else:
|
||||
shortanchor = anchor
|
||||
pdict[name] = (fn2index[docname], typeindex, prio, shortanchor)
|
||||
return rv
|
||||
|
||||
def get_terms(self, fn2index):
|
||||
|
@ -363,10 +363,13 @@ var Search = {
|
||||
var fullname = (prefix ? prefix + '.' : '') + name;
|
||||
if (fullname.toLowerCase().indexOf(object) > -1) {
|
||||
match = objects[prefix][name];
|
||||
descr = objnames[match[1]] + _(', in ') + titles[match[0]];
|
||||
// XXX the generated anchors are not generally correct
|
||||
// XXX there may be custom prefixes
|
||||
result = [filenames[match[0]], fullname, '#'+fullname, descr];
|
||||
descr = objnames[match[1]][0] + _(', in ') + titles[match[0]];
|
||||
anchor = match[3];
|
||||
if (anchor == '')
|
||||
anchor = fullname;
|
||||
else if (anchor == '-')
|
||||
anchor = objnames[match[1]][1] + '-' + fullname;
|
||||
result = [filenames[match[0]], fullname, '#'+anchor, descr];
|
||||
switch (match[2]) {
|
||||
case 1: objectResults.push(result); break;
|
||||
case 0: importantResults.push(result); break;
|
||||
|
Loading…
Reference in New Issue
Block a user