Rollup merge of #72650 - GuillaumeGomez:sort-sidebar-elements, r=kinnison
Sort sidebar elements r? @kinnison
This commit is contained in:
commit
5f0aefda49
@ -4067,9 +4067,9 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
|||||||
.filter(|i| i.inner_impl().trait_.is_none())
|
.filter(|i| i.inner_impl().trait_.is_none())
|
||||||
.flat_map(move |i| get_methods(i.inner_impl(), false, used_links_bor, false))
|
.flat_map(move |i| get_methods(i.inner_impl(), false, used_links_bor, false))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
// We want links' order to be reproducible so we don't use unstable sort.
|
|
||||||
ret.sort();
|
|
||||||
if !ret.is_empty() {
|
if !ret.is_empty() {
|
||||||
|
// We want links' order to be reproducible so we don't use unstable sort.
|
||||||
|
ret.sort();
|
||||||
out.push_str(&format!(
|
out.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#implementations\">Methods</a>\
|
"<a class=\"sidebar-title\" href=\"#implementations\">Methods</a>\
|
||||||
<div class=\"sidebar-links\">{}</div>",
|
<div class=\"sidebar-links\">{}</div>",
|
||||||
@ -4240,7 +4240,7 @@ fn is_negative_impl(i: &clean::Impl) -> bool {
|
|||||||
fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
||||||
let mut sidebar = String::new();
|
let mut sidebar = String::new();
|
||||||
|
|
||||||
let types = t
|
let mut types = t
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|m| match m.name {
|
.filter_map(|m| match m.name {
|
||||||
@ -4249,8 +4249,8 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
|||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect::<String>();
|
.collect::<Vec<_>>();
|
||||||
let consts = t
|
let mut consts = t
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|m| match m.name {
|
.filter_map(|m| match m.name {
|
||||||
@ -4259,7 +4259,7 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
|||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect::<String>();
|
.collect::<Vec<_>>();
|
||||||
let mut required = t
|
let mut required = t
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
@ -4282,24 +4282,26 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
|||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
if !types.is_empty() {
|
if !types.is_empty() {
|
||||||
|
types.sort();
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#associated-types\">\
|
"<a class=\"sidebar-title\" href=\"#associated-types\">\
|
||||||
Associated Types</a><div class=\"sidebar-links\">{}</div>",
|
Associated Types</a><div class=\"sidebar-links\">{}</div>",
|
||||||
types
|
types.join("")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !consts.is_empty() {
|
if !consts.is_empty() {
|
||||||
|
consts.sort();
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#associated-const\">\
|
"<a class=\"sidebar-title\" href=\"#associated-const\">\
|
||||||
Associated Constants</a><div class=\"sidebar-links\">{}</div>",
|
Associated Constants</a><div class=\"sidebar-links\">{}</div>",
|
||||||
consts
|
consts.join("")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !required.is_empty() {
|
if !required.is_empty() {
|
||||||
required.sort();
|
required.sort();
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#required-methods\">\
|
"<a class=\"sidebar-title\" href=\"#required-methods\">\
|
||||||
Required Methods</a><div class=\"sidebar-links\">{}</div>",
|
Required Methods</a><div class=\"sidebar-links\">{}</div>",
|
||||||
required.join("")
|
required.join("")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -4307,7 +4309,7 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
|||||||
provided.sort();
|
provided.sort();
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#provided-methods\">\
|
"<a class=\"sidebar-title\" href=\"#provided-methods\">\
|
||||||
Provided Methods</a><div class=\"sidebar-links\">{}</div>",
|
Provided Methods</a><div class=\"sidebar-links\">{}</div>",
|
||||||
provided.join("")
|
provided.join("")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -4325,8 +4327,8 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
|||||||
res.sort();
|
res.sort();
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#foreign-impls\">\
|
"<a class=\"sidebar-title\" href=\"#foreign-impls\">\
|
||||||
Implementations on Foreign Types</a><div \
|
Implementations on Foreign Types</a><div \
|
||||||
class=\"sidebar-links\">{}</div>",
|
class=\"sidebar-links\">{}</div>",
|
||||||
res.into_iter()
|
res.into_iter()
|
||||||
.map(|(name, id)| format!("<a href=\"#{}\">{}</a>", id, Escape(&name)))
|
.map(|(name, id)| format!("<a href=\"#{}\">{}</a>", id, Escape(&name)))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
@ -4339,7 +4341,7 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
|
|||||||
if t.auto {
|
if t.auto {
|
||||||
sidebar.push_str(
|
sidebar.push_str(
|
||||||
"<a class=\"sidebar-title\" \
|
"<a class=\"sidebar-title\" \
|
||||||
href=\"#synthetic-implementors\">Auto Implementors</a>",
|
href=\"#synthetic-implementors\">Auto Implementors</a>",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4365,18 +4367,18 @@ fn sidebar_typedef(buf: &mut Buffer, it: &clean::Item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_struct_fields_name(fields: &[clean::Item]) -> String {
|
fn get_struct_fields_name(fields: &[clean::Item]) -> String {
|
||||||
fields
|
let mut fields = fields
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| if let clean::StructFieldItem(..) = f.inner { true } else { false })
|
.filter(|f| if let clean::StructFieldItem(..) = f.inner { true } else { false })
|
||||||
.filter_map(|f| match f.name {
|
.filter_map(|f| match f.name {
|
||||||
Some(ref name) => Some(format!(
|
Some(ref name) => {
|
||||||
"<a href=\"#structfield.{name}\">\
|
Some(format!("<a href=\"#structfield.{name}\">{name}</a>", name = name))
|
||||||
{name}</a>",
|
}
|
||||||
name = name
|
|
||||||
)),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect::<Vec<_>>();
|
||||||
|
fields.sort();
|
||||||
|
fields.join("")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sidebar_union(buf: &mut Buffer, it: &clean::Item, u: &clean::Union) {
|
fn sidebar_union(buf: &mut Buffer, it: &clean::Item, u: &clean::Union) {
|
||||||
@ -4386,7 +4388,7 @@ fn sidebar_union(buf: &mut Buffer, it: &clean::Item, u: &clean::Union) {
|
|||||||
if !fields.is_empty() {
|
if !fields.is_empty() {
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#fields\">Fields</a>\
|
"<a class=\"sidebar-title\" href=\"#fields\">Fields</a>\
|
||||||
<div class=\"sidebar-links\">{}</div>",
|
<div class=\"sidebar-links\">{}</div>",
|
||||||
fields
|
fields
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -4401,23 +4403,20 @@ fn sidebar_union(buf: &mut Buffer, it: &clean::Item, u: &clean::Union) {
|
|||||||
fn sidebar_enum(buf: &mut Buffer, it: &clean::Item, e: &clean::Enum) {
|
fn sidebar_enum(buf: &mut Buffer, it: &clean::Item, e: &clean::Enum) {
|
||||||
let mut sidebar = String::new();
|
let mut sidebar = String::new();
|
||||||
|
|
||||||
let variants = e
|
let mut variants = e
|
||||||
.variants
|
.variants
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|v| match v.name {
|
.filter_map(|v| match v.name {
|
||||||
Some(ref name) => Some(format!(
|
Some(ref name) => Some(format!("<a href=\"#variant.{name}\">{name}</a>", name = name)),
|
||||||
"<a href=\"#variant.{name}\">{name}\
|
|
||||||
</a>",
|
|
||||||
name = name
|
|
||||||
)),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect::<String>();
|
.collect::<Vec<_>>();
|
||||||
if !variants.is_empty() {
|
if !variants.is_empty() {
|
||||||
|
variants.sort_unstable();
|
||||||
sidebar.push_str(&format!(
|
sidebar.push_str(&format!(
|
||||||
"<a class=\"sidebar-title\" href=\"#variants\">Variants</a>\
|
"<a class=\"sidebar-title\" href=\"#variants\">Variants</a>\
|
||||||
<div class=\"sidebar-links\">{}</div>",
|
<div class=\"sidebar-links\">{}</div>",
|
||||||
variants
|
variants.join(""),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user