Skip to content
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

rustdoc-search: fix description on aliases in results #124149

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 11 additions & 10 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,16 +1464,7 @@ function initSearch(rawSearchIndex) {
return 0;
});

const transformed = transformResults(result_list);
const descs = await Promise.all(transformed.map(result => {
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
"" :
searchState.loadDesc(result);
}));
for (const [i, result] of transformed.entries()) {
result.desc = descs[i];
}
return transformed;
return transformResults(result_list);
}

/**
Expand Down Expand Up @@ -2517,6 +2508,16 @@ function initSearch(rawSearchIndex) {
sorted_others,
parsedQuery);
handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate);
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
const descs = await Promise.all(list.map(result => {
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
"" :
searchState.loadDesc(result);
}));
for (const [i, result] of list.entries()) {
result.desc = descs[i];
}
}));
if (parsedQuery.error !== null && ret.others.length !== 0) {
// It means some doc aliases were found so let's "remove" the error!
ret.query.error = null;
Expand Down
6 changes: 5 additions & 1 deletion tests/rustdoc-js-std/alias-1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const EXPECTED = {
'query': '&',
'others': [
{ 'path': 'std', 'name': 'reference' },
{
'path': 'std',
'name': 'reference',
'desc': "References, <code>&amp;T</code> and <code>&amp;mut T</code>.",
},
],
};
Loading