Rollup merge of #93852 - GuillaumeGomez:remove-multi-query, r=jsha

rustdoc: remove support for multi-query search

This is needed by https://github.com/rust-lang/rust/pull/90630 to make feature changes non-existent.

cc `@camelid`
r? `@jsha`
This commit is contained in:
Matthias Krüger 2022-02-11 07:48:05 +01:00 committed by GitHub
commit b97ccebc7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 107 deletions

View File

@ -1197,110 +1197,19 @@ window.initSearch = function(rawSearchIndex) {
}
function execSearch(query, searchWords, filterCrates) {
function getSmallest(arrays, positions, notDuplicates) {
var start = null;
for (var it = 0, len = positions.length; it < len; ++it) {
if (arrays[it].length > positions[it] &&
(start === null || start > arrays[it][positions[it]].lev) &&
!notDuplicates[arrays[it][positions[it]].fullPath]) {
start = arrays[it][positions[it]].lev;
}
}
return start;
}
function mergeArrays(arrays) {
var ret = [];
var positions = [];
var notDuplicates = {};
for (var x = 0, arrays_len = arrays.length; x < arrays_len; ++x) {
positions.push(0);
}
while (ret.length < MAX_RESULTS) {
var smallest = getSmallest(arrays, positions, notDuplicates);
if (smallest === null) {
break;
}
for (x = 0; x < arrays_len && ret.length < MAX_RESULTS; ++x) {
if (arrays[x].length > positions[x] &&
arrays[x][positions[x]].lev === smallest &&
!notDuplicates[arrays[x][positions[x]].fullPath]) {
ret.push(arrays[x][positions[x]]);
notDuplicates[arrays[x][positions[x]].fullPath] = true;
positions[x] += 1;
}
}
}
return ret;
}
// Split search query by ",", while respecting angle bracket nesting.
// Since "<" is an alias for the Ord family of traits, it also uses
// lookahead to distinguish "<"-as-less-than from "<"-as-angle-bracket.
//
// tokenizeQuery("A<B, C>, D") == ["A<B, C>", "D"]
// tokenizeQuery("A<B, C, D") == ["A<B", "C", "D"]
function tokenizeQuery(raw) {
var i, matched;
var l = raw.length;
var depth = 0;
var nextAngle = /(<|>)/g;
var ret = [];
var start = 0;
for (i = 0; i < l; ++i) {
switch (raw[i]) {
case "<":
nextAngle.lastIndex = i + 1;
matched = nextAngle.exec(raw);
if (matched && matched[1] === '>') {
depth += 1;
}
break;
case ">":
if (depth > 0) {
depth -= 1;
}
break;
case ",":
if (depth === 0) {
ret.push(raw.substring(start, i));
start = i + 1;
}
break;
}
}
if (start !== i) {
ret.push(raw.substring(start, i));
}
return ret;
}
var queries = tokenizeQuery(query.raw);
query = query.raw.trim();
var results = {
"in_args": [],
"returned": [],
"others": [],
};
for (var i = 0, len = queries.length; i < len; ++i) {
query = queries[i].trim();
if (query.length !== 0) {
var tmp = execQuery(getQuery(query), searchWords, filterCrates);
if (query.length !== 0) {
var tmp = execQuery(getQuery(query), searchWords, filterCrates);
results.in_args.push(tmp.in_args);
results.returned.push(tmp.returned);
results.others.push(tmp.others);
}
}
if (queries.length > 1) {
return {
"in_args": mergeArrays(results.in_args),
"returned": mergeArrays(results.returned),
"others": mergeArrays(results.others),
};
results.in_args.push(tmp.in_args);
results.returned.push(tmp.returned);
results.others.push(tmp.others);
}
return {
"in_args": results.in_args[0],

View File

@ -1,10 +0,0 @@
const QUERY = 'str,u8';
const EXPECTED = {
'others': [
{ 'path': 'std', 'name': 'str', 'href': '../std/primitive.str.html' },
{ 'path': 'std', 'name': 'u8', 'href': '../std/primitive.u8.html' },
{ 'path': 'std', 'name': 'str', 'href': '../std/str/index.html' },
{ 'path': 'std', 'name': 'u8', 'href': '../std/u8/index.html' },
],
};