mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #145100 - GuillaumeGomez:rank-doc-alias-lower, r=lolbinarycat
Rank doc aliases lower than equivalently matched items Follow-up of https://github.com/rust-lang/rust/pull/143988. cc `@lolbinarycat`
This commit is contained in:
@@ -3365,6 +3365,13 @@ class DocSearch {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
// sort doc alias items later
|
||||
a = Number(aaa.item.is_alias === true);
|
||||
b = Number(bbb.item.is_alias === true);
|
||||
if (a !== b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
// sort by item name (lexicographically larger goes later)
|
||||
let aw = aaa.word;
|
||||
let bw = bbb.word;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// exact-check
|
||||
|
||||
// Checking that doc aliases are always listed after items with equivalent matching.
|
||||
|
||||
const EXPECTED = [
|
||||
{
|
||||
'query': 'coo',
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias_after_other_items',
|
||||
'name': 'Foo',
|
||||
'href': '../doc_alias_after_other_items/struct.Foo.html',
|
||||
},
|
||||
{
|
||||
'path': 'doc_alias_after_other_items',
|
||||
'name': 'bar',
|
||||
'alias': 'Boo',
|
||||
'is_alias': true
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'query': '"confiture"',
|
||||
'others': [
|
||||
{
|
||||
'path': 'doc_alias_after_other_items',
|
||||
'name': 'Confiture',
|
||||
'href': '../doc_alias_after_other_items/struct.Confiture.html',
|
||||
},
|
||||
{
|
||||
'path': 'doc_alias_after_other_items',
|
||||
'name': 'this_is_a_long_name',
|
||||
'alias': 'Confiture',
|
||||
'is_alias': true
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,9 @@
|
||||
pub struct Foo;
|
||||
|
||||
#[doc(alias = "Boo")]
|
||||
pub fn bar() {}
|
||||
|
||||
pub struct Confiture;
|
||||
|
||||
#[doc(alias = "Confiture")]
|
||||
pub fn this_is_a_long_name() {}
|
||||
Reference in New Issue
Block a user