Rollup merge of #46700 - GuillaumeGomez:more-relevant-doc-search, r=QuietMisdreavus

make doc search more relevant

Fixes #46595.

r? @QuietMisdreavus

If possible, I'd appreciate a strong check on this PR. :3
This commit is contained in:
Guillaume Gomez 2017-12-18 23:08:30 +01:00 committed by GitHub
commit 9ab2227db1

View file

@ -681,6 +681,9 @@
}
function checkPath(startsWith, lastElem, ty) {
if (startsWith.length === 0) {
return 0;
}
var ret_lev = MAX_LEV_DISTANCE + 1;
var path = ty.path.split("::");
@ -706,18 +709,7 @@
lev_total += lev;
}
if (aborted === false) {
var extra = MAX_LEV_DISTANCE + 1;
if (i + startsWith.length < path.length) {
extra = levenshtein(path[i + startsWith.length], lastElem);
}
if (extra > MAX_LEV_DISTANCE) {
extra = levenshtein(ty.name, lastElem);
}
if (extra < MAX_LEV_DISTANCE + 1) {
lev_total += extra;
ret_lev = Math.min(ret_lev,
Math.round(lev_total / (startsWith.length + 1)));
}
ret_lev = Math.min(ret_lev, Math.round(lev_total / startsWith.length));
}
}
return ret_lev;
@ -934,6 +926,13 @@
}
lev += lev_add;
if (lev > 0 && val.length > 3 && searchWords[j].startsWith(val)) {
if (val.length < 6) {
lev -= 1;
} else {
lev = 0;
}
}
if (in_args <= MAX_LEV_DISTANCE) {
if (results_in_args[fullId] === undefined) {
results_in_args[fullId] = {