Moved non_exhaustive message to fields/variants section and onto type.
This commit is contained in:
parent
5ccafa106f
commit
9527d6ade7
3 changed files with 18 additions and 19 deletions
|
@ -2194,7 +2194,6 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
|
||||||
info!("Documenting {}", name);
|
info!("Documenting {}", name);
|
||||||
}
|
}
|
||||||
document_stability(w, cx, item)?;
|
document_stability(w, cx, item)?;
|
||||||
document_non_exhaustive(w, item)?;
|
|
||||||
let prefix = render_assoc_const_value(item);
|
let prefix = render_assoc_const_value(item);
|
||||||
document_full(w, item, cx, &prefix)?;
|
document_full(w, item, cx, &prefix)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2263,20 +2262,13 @@ fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item)
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn document_non_exhaustive_header(item: &clean::Item) -> &str {
|
||||||
|
if item.is_non_exhaustive() { " (Non-exhaustive)" } else { "" }
|
||||||
|
}
|
||||||
|
|
||||||
fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
|
fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
|
||||||
if item.is_non_exhaustive() {
|
if item.is_non_exhaustive() {
|
||||||
write!(w, "<div class='non-exhaustive'><div class='stab non-exhaustive'>")?;
|
write!(w, "<p class='non-exhaustive'>")?;
|
||||||
write!(w, "<details><summary><span class=microscope>🔬</span>")?;
|
|
||||||
|
|
||||||
if item.is_struct() {
|
|
||||||
write!(w, "This struct is marked as non exhaustive.")?;
|
|
||||||
} else if item.is_enum() {
|
|
||||||
write!(w, "This enum is marked as non exhaustive.")?;
|
|
||||||
} else {
|
|
||||||
write!(w, "This type is marked as non exhaustive.")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
write!(w, "</summary><p>")?;
|
|
||||||
|
|
||||||
if item.is_struct() {
|
if item.is_struct() {
|
||||||
write!(w, "This struct is marked as non-exhaustive as additional fields may be \
|
write!(w, "This struct is marked as non-exhaustive as additional fields may be \
|
||||||
|
@ -2293,7 +2285,7 @@ fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::R
|
||||||
constructors.")?;
|
constructors.")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(w, "</p></details></div></div>")?;
|
write!(w, "</p>")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -3159,7 +3151,9 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
if let doctree::Plain = s.struct_type {
|
if let doctree::Plain = s.struct_type {
|
||||||
if fields.peek().is_some() {
|
if fields.peek().is_some() {
|
||||||
write!(w, "<h2 id='fields' class='fields small-section-header'>
|
write!(w, "<h2 id='fields' class='fields small-section-header'>
|
||||||
Fields<a href='#fields' class='anchor'></a></h2>")?;
|
Fields{}<a href='#fields' class='anchor'></a></h2>",
|
||||||
|
document_non_exhaustive_header(it))?;
|
||||||
|
document_non_exhaustive(w, it)?;
|
||||||
for (field, ty) in fields {
|
for (field, ty) in fields {
|
||||||
let id = derive_id(format!("{}.{}",
|
let id = derive_id(format!("{}.{}",
|
||||||
ItemType::StructField,
|
ItemType::StructField,
|
||||||
|
@ -3291,7 +3285,9 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
document(w, cx, it)?;
|
document(w, cx, it)?;
|
||||||
if !e.variants.is_empty() {
|
if !e.variants.is_empty() {
|
||||||
write!(w, "<h2 id='variants' class='variants small-section-header'>
|
write!(w, "<h2 id='variants' class='variants small-section-header'>
|
||||||
Variants<a href='#variants' class='anchor'></a></h2>\n")?;
|
Variants{}<a href='#variants' class='anchor'></a></h2>\n",
|
||||||
|
document_non_exhaustive_header(it))?;
|
||||||
|
document_non_exhaustive(w, it)?;
|
||||||
for variant in &e.variants {
|
for variant in &e.variants {
|
||||||
let id = derive_id(format!("{}.{}",
|
let id = derive_id(format!("{}.{}",
|
||||||
ItemType::Variant,
|
ItemType::Variant,
|
||||||
|
@ -3392,7 +3388,8 @@ const ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
|
||||||
"must_use",
|
"must_use",
|
||||||
"no_mangle",
|
"no_mangle",
|
||||||
"repr",
|
"repr",
|
||||||
"unsafe_destructor_blind_to_params"
|
"unsafe_destructor_blind_to_params",
|
||||||
|
"non_exhaustive"
|
||||||
];
|
];
|
||||||
|
|
||||||
fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
||||||
|
|
|
@ -148,6 +148,8 @@ pre {
|
||||||
.content .fnname{ color: #2BAB63; }
|
.content .fnname{ color: #2BAB63; }
|
||||||
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
|
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
|
||||||
|
|
||||||
|
.non-exhaustive { color: #DDD; margin-bottom: 1em; }
|
||||||
|
|
||||||
pre.rust .comment { color: #8d8d8b; }
|
pre.rust .comment { color: #8d8d8b; }
|
||||||
pre.rust .doccomment { color: #8ca375; }
|
pre.rust .doccomment { color: #8ca375; }
|
||||||
|
|
||||||
|
@ -188,7 +190,6 @@ a.test-arrow {
|
||||||
border-color: #008dfd;
|
border-color: #008dfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stab.non-exhaustive { background: #2a2a2a; border-color: #707070; }
|
|
||||||
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #404040; }
|
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #404040; }
|
||||||
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #404040; }
|
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #404040; }
|
||||||
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #404040; }
|
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #404040; }
|
||||||
|
|
|
@ -148,6 +148,8 @@ pre {
|
||||||
.content .fnname { color: #9a6e31; }
|
.content .fnname { color: #9a6e31; }
|
||||||
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
|
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
|
||||||
|
|
||||||
|
.non-exhaustive { color: #222; margin-bottom: 1em; }
|
||||||
|
|
||||||
pre.rust .comment { color: #8E908C; }
|
pre.rust .comment { color: #8E908C; }
|
||||||
pre.rust .doccomment { color: #4D4D4C; }
|
pre.rust .doccomment { color: #4D4D4C; }
|
||||||
|
|
||||||
|
@ -188,7 +190,6 @@ a.test-arrow {
|
||||||
border-color: #66afe9;
|
border-color: #66afe9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stab.non-exhaustive { background: #F5F5F5; border-color: #D3D3D3; }
|
|
||||||
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
|
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
|
||||||
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
|
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
|
||||||
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
|
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue