mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Fix sub-variant doc display
This commit is contained in:
parent
42c11de47b
commit
2fd378b82b
@ -3379,10 +3379,10 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
let variant_id = cx.derive_id(format!("{}.{}.fields",
|
||||
ItemType::Variant,
|
||||
variant.name.as_ref().unwrap()));
|
||||
write!(w, "<span class='docblock autohide sub-variant' id='{id}'>",
|
||||
write!(w, "<span class='autohide sub-variant' id='{id}'>",
|
||||
id = variant_id)?;
|
||||
write!(w, "<h3 class='fields'>Fields of <code>{name}</code></h3>\n
|
||||
<table>", name = variant.name.as_ref().unwrap())?;
|
||||
write!(w, "<h3>Fields of <b>{name}</b></h3><div>",
|
||||
name = variant.name.as_ref().unwrap())?;
|
||||
for field in &s.fields {
|
||||
use clean::StructFieldItem;
|
||||
if let StructFieldItem(ref ty) = field.inner {
|
||||
@ -3394,19 +3394,18 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
ItemType::Variant.name_space(),
|
||||
field.name.as_ref().unwrap(),
|
||||
ItemType::StructField.name_space()));
|
||||
write!(w, "<tr><td \
|
||||
id='{id}'>\
|
||||
<span id='{ns_id}' class='invisible'>\
|
||||
<code>{f}: {t}</code></span></td><td>",
|
||||
write!(w, "<span id=\"{id}\" class=\"variant small-section-header\">\
|
||||
<a href=\"#{id}\" class=\"anchor field\"></a>\
|
||||
<span id='{ns_id}' class='invisible'><code>{f}: {t}\
|
||||
</code></span></span>",
|
||||
id = id,
|
||||
ns_id = ns_id,
|
||||
f = field.name.as_ref().unwrap(),
|
||||
t = *ty)?;
|
||||
document(w, cx, field)?;
|
||||
write!(w, "</td></tr>")?;
|
||||
}
|
||||
}
|
||||
write!(w, "</table></span>")?;
|
||||
write!(w, "</div></span>")?;
|
||||
}
|
||||
render_stability_since(w, variant, it)?;
|
||||
}
|
||||
|
@ -1886,7 +1886,7 @@
|
||||
if (hasClass(relatedDoc, "stability")) {
|
||||
relatedDoc = relatedDoc.nextElementSibling;
|
||||
}
|
||||
if (hasClass(relatedDoc, "docblock")) {
|
||||
if (hasClass(relatedDoc, "docblock") || hasClass(relatedDoc, "sub-variant")) {
|
||||
var action = mode;
|
||||
if (action === "toggle") {
|
||||
if (hasClass(relatedDoc, "hidden-by-usual-hider")) {
|
||||
@ -2094,15 +2094,13 @@
|
||||
}
|
||||
|
||||
var hideItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
|
||||
onEach(document.getElementsByClassName('docblock'), function(e) {
|
||||
function buildToggleWrapper(e) {
|
||||
if (hasClass(e, 'autohide')) {
|
||||
var wrap = e.previousElementSibling;
|
||||
if (wrap && hasClass(wrap, 'toggle-wrapper')) {
|
||||
var toggle = wrap.childNodes[0];
|
||||
var extra = false;
|
||||
if (e.childNodes[0].tagName === 'H3') {
|
||||
extra = true;
|
||||
}
|
||||
var extra = e.childNodes[0].tagName === 'H3';
|
||||
|
||||
e.style.display = 'none';
|
||||
addClass(wrap, 'collapsed');
|
||||
onEach(toggle.getElementsByClassName('inner'), function(e) {
|
||||
@ -2127,6 +2125,8 @@
|
||||
if (hideItemDeclarations === false) {
|
||||
extraClass = 'collapsed';
|
||||
}
|
||||
} else if (hasClass(e, "sub-variant")) {
|
||||
otherMessage = ' Show fields';
|
||||
} else if (hasClass(e, "non-exhaustive")) {
|
||||
otherMessage = ' This ';
|
||||
if (hasClass(e, "non-exhaustive-struct")) {
|
||||
@ -2150,7 +2150,10 @@
|
||||
collapseDocs(e.previousSibling.childNodes[0], "toggle");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onEach(document.getElementsByClassName('docblock'), buildToggleWrapper);
|
||||
onEach(document.getElementsByClassName('sub-variant'), buildToggleWrapper);
|
||||
|
||||
function createToggleWrapper(tog) {
|
||||
var span = document.createElement('span');
|
||||
|
@ -517,6 +517,10 @@ h4 > code, h3 > code, .invisible > code {
|
||||
margin-top: -13px;
|
||||
}
|
||||
|
||||
.sub-variant > div > .stability {
|
||||
margin-top: initial;
|
||||
}
|
||||
|
||||
.content .stability::before {
|
||||
content: '˪';
|
||||
font-size: 30px;
|
||||
@ -866,7 +870,23 @@ span.since {
|
||||
}
|
||||
|
||||
.sub-variant, .sub-variant > h3 {
|
||||
margin-top: 0 !important;
|
||||
margin-top: 1px !important;
|
||||
}
|
||||
|
||||
#main > .sub-variant > h3 {
|
||||
font-size: 15px;
|
||||
margin-left: 25px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.sub-variant > div {
|
||||
margin-left: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.sub-variant > div > span {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
|
Loading…
Reference in New Issue
Block a user