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:
commit
cd1e82ac72
3 changed files with 54 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
38
tests/rustdoc-js/doc-alias-after-other-items.js
Normal file
38
tests/rustdoc-js/doc-alias-after-other-items.js
Normal file
|
|
@ -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
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
9
tests/rustdoc-js/doc-alias-after-other-items.rs
Normal file
9
tests/rustdoc-js/doc-alias-after-other-items.rs
Normal file
|
|
@ -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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue