Don't hide fields of enum struct variants
* The toggle adds visual clutter * It's easy to miss that there are fields * Tuple variant fields are always shown, so it is inconsistent to hide struct variant fields * It's annoying to have to click the toggle every time
This commit is contained in:
parent
e742158ef5
commit
97623bf051
3 changed files with 4 additions and 9 deletions
|
@ -1029,14 +1029,12 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
|
||||||
|
|
||||||
use crate::clean::Variant;
|
use crate::clean::Variant;
|
||||||
if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
|
if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
|
||||||
let count_fields = s.fields.len();
|
|
||||||
toggle_open(w, format_args!("{} field{}", count_fields, pluralize(count_fields)));
|
|
||||||
let variant_id = cx.derive_id(format!(
|
let variant_id = cx.derive_id(format!(
|
||||||
"{}.{}.fields",
|
"{}.{}.fields",
|
||||||
ItemType::Variant,
|
ItemType::Variant,
|
||||||
variant.name.as_ref().unwrap()
|
variant.name.as_ref().unwrap()
|
||||||
));
|
));
|
||||||
write!(w, "<div class=\"autohide sub-variant\" id=\"{id}\">", id = variant_id);
|
write!(w, "<div class=\"sub-variant\" id=\"{id}\">", id = variant_id);
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<h3>Fields of <b>{name}</b></h3><div>",
|
"<h3>Fields of <b>{name}</b></h3><div>",
|
||||||
|
@ -1064,7 +1062,6 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.write_str("</div></div>");
|
w.write_str("</div></div>");
|
||||||
toggle_close(w);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ a.test-arrow:hover{
|
||||||
padding-top: 1px;
|
padding-top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main > details > .sub-variant > h3 {
|
#main .sub-variant > h3 {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
margin-left: 25px;
|
margin-left: 25px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
|
|
|
@ -62,8 +62,7 @@ pub struct PrivStruct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has 'toggle_item_contents/enum.Enum.html'
|
// @has 'toggle_item_contents/enum.Enum.html'
|
||||||
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1
|
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]'
|
||||||
// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 2 fields'
|
|
||||||
pub enum Enum {
|
pub enum Enum {
|
||||||
A, B, C,
|
A, B, C,
|
||||||
D {
|
D {
|
||||||
|
@ -73,8 +72,7 @@ pub enum Enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has 'toggle_item_contents/enum.EnumStructVariant.html'
|
// @has 'toggle_item_contents/enum.EnumStructVariant.html'
|
||||||
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1
|
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]'
|
||||||
// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 1 field'
|
|
||||||
pub enum EnumStructVariant {
|
pub enum EnumStructVariant {
|
||||||
A, B, C,
|
A, B, C,
|
||||||
D {
|
D {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue