Skip to content

make doc search more relevant #46700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("::");

Expand All @@ -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;
Expand Down Expand Up @@ -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] = {
Expand Down