Skip to content

Commit 862c248

Browse files
authored
Unrolled build for #145100
Rollup merge of #145100 - GuillaumeGomez:rank-doc-alias-lower, r=lolbinarycat Rank doc aliases lower than equivalently matched items Follow-up of #143988. cc `@lolbinarycat`
2 parents 2de2456 + a34bd2b commit 862c248

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,6 +3340,13 @@ class DocSearch {
33403340
return a - b;
33413341
}
33423342

3343+
// sort doc alias items later
3344+
a = Number(aaa.item.is_alias === true);
3345+
b = Number(bbb.item.is_alias === true);
3346+
if (a !== b) {
3347+
return a - b;
3348+
}
3349+
33433350
// sort by item name (lexicographically larger goes later)
33443351
let aw = aaa.word;
33453352
let bw = bbb.word;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// exact-check
2+
3+
// Checking that doc aliases are always listed after items with equivalent matching.
4+
5+
const EXPECTED = [
6+
{
7+
'query': 'coo',
8+
'others': [
9+
{
10+
'path': 'doc_alias_after_other_items',
11+
'name': 'Foo',
12+
'href': '../doc_alias_after_other_items/struct.Foo.html',
13+
},
14+
{
15+
'path': 'doc_alias_after_other_items',
16+
'name': 'bar',
17+
'alias': 'Boo',
18+
'is_alias': true
19+
},
20+
],
21+
},
22+
{
23+
'query': '"confiture"',
24+
'others': [
25+
{
26+
'path': 'doc_alias_after_other_items',
27+
'name': 'Confiture',
28+
'href': '../doc_alias_after_other_items/struct.Confiture.html',
29+
},
30+
{
31+
'path': 'doc_alias_after_other_items',
32+
'name': 'this_is_a_long_name',
33+
'alias': 'Confiture',
34+
'is_alias': true
35+
},
36+
],
37+
},
38+
];
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub struct Foo;
2+
3+
#[doc(alias = "Boo")]
4+
pub fn bar() {}
5+
6+
pub struct Confiture;
7+
8+
#[doc(alias = "Confiture")]
9+
pub fn this_is_a_long_name() {}

0 commit comments

Comments
 (0)