Sort fields, variants and other unsorted elements in the sidebar
This commit is contained in:
parent
9eedd138ee
commit
5ba5b65367
1 changed files with 31 additions and 32 deletions
|
@ -4064,9 +4064,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<_>>();
|
||||||
|
if !ret.is_empty() {
|
||||||
// We want links' order to be reproducible so we don't use unstable sort.
|
// We want links' order to be reproducible so we don't use unstable sort.
|
||||||
ret.sort();
|
ret.sort();
|
||||||
if !ret.is_empty() {
|
|
||||||
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>",
|
||||||
|
@ -4237,7 +4237,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 {
|
||||||
|
@ -4246,8 +4246,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 {
|
||||||
|
@ -4256,7 +4256,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()
|
||||||
|
@ -4279,17 +4279,19 @@ 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() {
|
||||||
|
@ -4362,18 +4364,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) {
|
||||||
|
@ -4398,23 +4400,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…
Add table
Add a link
Reference in a new issue