mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
merge with stable
This commit is contained in:
commit
9ae95df450
4
CHANGES
4
CHANGES
@ -78,6 +78,10 @@ Bugs fixed
|
||||
config value for 'version' and 'release'.
|
||||
* #2102: On Windows + Py3, using ``|today|`` and non-ASCII date format will raise
|
||||
UnicodeEncodeError.
|
||||
* #1974: UnboundLocalError: local variable 'domain' referenced before assignment when
|
||||
using `any` role and `sphinx.ext.intersphinx` in same time.
|
||||
* #2121: multiple words search doesn't find pages when words across on the page title and
|
||||
the page content.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
@ -326,6 +326,7 @@ def missing_reference(app, env, node, contnode):
|
||||
objtypes = ['%s:%s' % (domain.name, objtype)
|
||||
for domain in env.domains.values()
|
||||
for objtype in domain.object_types]
|
||||
domain = None
|
||||
elif node['reftype'] == 'doc':
|
||||
domain = 'std' # special case
|
||||
objtypes = ['std:doc']
|
||||
|
@ -195,7 +195,7 @@ var Search = {
|
||||
}
|
||||
|
||||
// lookup as search terms in fulltext
|
||||
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));
|
||||
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));
|
||||
|
||||
// let the scorer override scores with a custom scoring function
|
||||
if (Scorer.score) {
|
||||
@ -363,7 +363,7 @@ var Search = {
|
||||
var filenames = this._index.filenames;
|
||||
var titles = this._index.titles;
|
||||
|
||||
var i, j, file, files;
|
||||
var i, j, file;
|
||||
var fileMap = {};
|
||||
var scoreMap = {};
|
||||
var results = [];
|
||||
@ -371,42 +371,34 @@ var Search = {
|
||||
// perform the search on the required terms
|
||||
for (i = 0; i < searchterms.length; i++) {
|
||||
var word = searchterms[i];
|
||||
|
||||
files = [];
|
||||
_files1 = terms[word];
|
||||
_files2 = titleterms[word];
|
||||
var files = [];
|
||||
var _o = [
|
||||
{files: terms[word], score: Scorer.term},
|
||||
{files: titleterms[word], score: Scorer.title}
|
||||
];
|
||||
|
||||
// no match but word was a required one
|
||||
if (_files1 === undefined && _files2 === undefined) {
|
||||
if ($u.every(_o, function(o){return o.files === undefined;})) {
|
||||
break;
|
||||
}
|
||||
// found search word in contents
|
||||
if (_files1 !== undefined) {
|
||||
if (_files1.length === undefined)
|
||||
_files1 = [_files1];
|
||||
files = files.concat(_files1);
|
||||
$u.each(_o, function(o) {
|
||||
var _files = o.files;
|
||||
if (_files === undefined)
|
||||
return
|
||||
|
||||
if (_files.length === undefined)
|
||||
_files = [_files];
|
||||
files = files.concat(_files);
|
||||
|
||||
// set score for the word in each file to Scorer.term
|
||||
for (j = 0; j < _files1.length; j++) {
|
||||
file = _files1[j];
|
||||
for (j = 0; j < _files.length; j++) {
|
||||
file = _files[j];
|
||||
if (!(file in scoreMap))
|
||||
scoreMap[file] = {}
|
||||
scoreMap[file][word] = Scorer.term;
|
||||
scoreMap[file][word] = o.score;
|
||||
}
|
||||
}
|
||||
if (_files2 !== undefined) {
|
||||
// found the word in document title
|
||||
if (_files2.length === undefined)
|
||||
_files2 = [_files2];
|
||||
files = files.concat(_files2);
|
||||
|
||||
// set score for the word in each file to Scorer.title
|
||||
for (j = 0; j < _files2.length; j++) {
|
||||
file = _files2[j];
|
||||
if (!(file in scoreMap))
|
||||
scoreMap[file] = {}
|
||||
scoreMap[file][word] = Scorer.title;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// create the mapping
|
||||
for (j = 0; j < files.length; j++) {
|
||||
@ -441,12 +433,7 @@ var Search = {
|
||||
if (valid) {
|
||||
// select one (max) score for the file.
|
||||
// for better ranking, we should calculate ranking by using words statistics like basic tf-idf...
|
||||
score = 0;
|
||||
for (i = 0; i < fileMap[file].length; i++) {
|
||||
w = fileMap[file][i];
|
||||
if (score < scoreMap[file][w])
|
||||
score = scoreMap[file][w]
|
||||
}
|
||||
var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]}));
|
||||
results.push([filenames[file], titles[file], '', null, score]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user