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",
|
let variant_id = cx.derive_id(format!("{}.{}.fields",
|
||||||
ItemType::Variant,
|
ItemType::Variant,
|
||||||
variant.name.as_ref().unwrap()));
|
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)?;
|
id = variant_id)?;
|
||||||
write!(w, "<h3 class='fields'>Fields of <code>{name}</code></h3>\n
|
write!(w, "<h3>Fields of <b>{name}</b></h3><div>",
|
||||||
<table>", name = variant.name.as_ref().unwrap())?;
|
name = variant.name.as_ref().unwrap())?;
|
||||||
for field in &s.fields {
|
for field in &s.fields {
|
||||||
use clean::StructFieldItem;
|
use clean::StructFieldItem;
|
||||||
if let StructFieldItem(ref ty) = field.inner {
|
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(),
|
ItemType::Variant.name_space(),
|
||||||
field.name.as_ref().unwrap(),
|
field.name.as_ref().unwrap(),
|
||||||
ItemType::StructField.name_space()));
|
ItemType::StructField.name_space()));
|
||||||
write!(w, "<tr><td \
|
write!(w, "<span id=\"{id}\" class=\"variant small-section-header\">\
|
||||||
id='{id}'>\
|
<a href=\"#{id}\" class=\"anchor field\"></a>\
|
||||||
<span id='{ns_id}' class='invisible'>\
|
<span id='{ns_id}' class='invisible'><code>{f}: {t}\
|
||||||
<code>{f}: {t}</code></span></td><td>",
|
</code></span></span>",
|
||||||
id = id,
|
id = id,
|
||||||
ns_id = ns_id,
|
ns_id = ns_id,
|
||||||
f = field.name.as_ref().unwrap(),
|
f = field.name.as_ref().unwrap(),
|
||||||
t = *ty)?;
|
t = *ty)?;
|
||||||
document(w, cx, field)?;
|
document(w, cx, field)?;
|
||||||
write!(w, "</td></tr>")?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(w, "</table></span>")?;
|
write!(w, "</div></span>")?;
|
||||||
}
|
}
|
||||||
render_stability_since(w, variant, it)?;
|
render_stability_since(w, variant, it)?;
|
||||||
}
|
}
|
||||||
|
@ -1886,7 +1886,7 @@
|
|||||||
if (hasClass(relatedDoc, "stability")) {
|
if (hasClass(relatedDoc, "stability")) {
|
||||||
relatedDoc = relatedDoc.nextElementSibling;
|
relatedDoc = relatedDoc.nextElementSibling;
|
||||||
}
|
}
|
||||||
if (hasClass(relatedDoc, "docblock")) {
|
if (hasClass(relatedDoc, "docblock") || hasClass(relatedDoc, "sub-variant")) {
|
||||||
var action = mode;
|
var action = mode;
|
||||||
if (action === "toggle") {
|
if (action === "toggle") {
|
||||||
if (hasClass(relatedDoc, "hidden-by-usual-hider")) {
|
if (hasClass(relatedDoc, "hidden-by-usual-hider")) {
|
||||||
@ -2094,15 +2094,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var hideItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
|
var hideItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
|
||||||
onEach(document.getElementsByClassName('docblock'), function(e) {
|
function buildToggleWrapper(e) {
|
||||||
if (hasClass(e, 'autohide')) {
|
if (hasClass(e, 'autohide')) {
|
||||||
var wrap = e.previousElementSibling;
|
var wrap = e.previousElementSibling;
|
||||||
if (wrap && hasClass(wrap, 'toggle-wrapper')) {
|
if (wrap && hasClass(wrap, 'toggle-wrapper')) {
|
||||||
var toggle = wrap.childNodes[0];
|
var toggle = wrap.childNodes[0];
|
||||||
var extra = false;
|
var extra = e.childNodes[0].tagName === 'H3';
|
||||||
if (e.childNodes[0].tagName === 'H3') {
|
|
||||||
extra = true;
|
|
||||||
}
|
|
||||||
e.style.display = 'none';
|
e.style.display = 'none';
|
||||||
addClass(wrap, 'collapsed');
|
addClass(wrap, 'collapsed');
|
||||||
onEach(toggle.getElementsByClassName('inner'), function(e) {
|
onEach(toggle.getElementsByClassName('inner'), function(e) {
|
||||||
@ -2127,6 +2125,8 @@
|
|||||||
if (hideItemDeclarations === false) {
|
if (hideItemDeclarations === false) {
|
||||||
extraClass = 'collapsed';
|
extraClass = 'collapsed';
|
||||||
}
|
}
|
||||||
|
} else if (hasClass(e, "sub-variant")) {
|
||||||
|
otherMessage = ' Show fields';
|
||||||
} else if (hasClass(e, "non-exhaustive")) {
|
} else if (hasClass(e, "non-exhaustive")) {
|
||||||
otherMessage = ' This ';
|
otherMessage = ' This ';
|
||||||
if (hasClass(e, "non-exhaustive-struct")) {
|
if (hasClass(e, "non-exhaustive-struct")) {
|
||||||
@ -2150,7 +2150,10 @@
|
|||||||
collapseDocs(e.previousSibling.childNodes[0], "toggle");
|
collapseDocs(e.previousSibling.childNodes[0], "toggle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
onEach(document.getElementsByClassName('docblock'), buildToggleWrapper);
|
||||||
|
onEach(document.getElementsByClassName('sub-variant'), buildToggleWrapper);
|
||||||
|
|
||||||
function createToggleWrapper(tog) {
|
function createToggleWrapper(tog) {
|
||||||
var span = document.createElement('span');
|
var span = document.createElement('span');
|
||||||
|
@ -517,6 +517,10 @@ h4 > code, h3 > code, .invisible > code {
|
|||||||
margin-top: -13px;
|
margin-top: -13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sub-variant > div > .stability {
|
||||||
|
margin-top: initial;
|
||||||
|
}
|
||||||
|
|
||||||
.content .stability::before {
|
.content .stability::before {
|
||||||
content: '˪';
|
content: '˪';
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
@ -866,7 +870,23 @@ span.since {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sub-variant, .sub-variant > h3 {
|
.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 {
|
.toggle-label {
|
||||||
|
Loading…
Reference in New Issue
Block a user