Add support for tuple structs' fields documentation
This commit is contained in:
parent
478126c0f3
commit
ec76b6eedd
2 changed files with 12 additions and 9 deletions
|
@ -2007,6 +2007,9 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebar.push_str("</div>");
|
sidebar.push_str("</div>");
|
||||||
|
} else if let CtorKind::Fn = s.struct_type {
|
||||||
|
sidebar
|
||||||
|
.push_str("<h3 class=\"sidebar-title\"><a href=\"#fields\">Tuple Fields</a></h3>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1176,21 +1176,21 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.peekable();
|
.peekable();
|
||||||
if let CtorKind::Fictive = s.struct_type {
|
if let CtorKind::Fictive | CtorKind::Fn = s.struct_type {
|
||||||
if fields.peek().is_some() {
|
if fields.peek().is_some() {
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<h2 id=\"fields\" class=\"fields small-section-header\">\
|
"<h2 id=\"fields\" class=\"fields small-section-header\">\
|
||||||
Fields{}<a href=\"#fields\" class=\"anchor\"></a></h2>",
|
{}{}<a href=\"#fields\" class=\"anchor\"></a>\
|
||||||
|
</h2>",
|
||||||
|
if let CtorKind::Fictive = s.struct_type { "Fields" } else { "Tuple Fields" },
|
||||||
document_non_exhaustive_header(it)
|
document_non_exhaustive_header(it)
|
||||||
);
|
);
|
||||||
document_non_exhaustive(w, it);
|
document_non_exhaustive(w, it);
|
||||||
for (field, ty) in fields {
|
for (index, (field, ty)) in fields.enumerate() {
|
||||||
let id = cx.derive_id(format!(
|
let field_name =
|
||||||
"{}.{}",
|
field.name.map_or_else(|| index.to_string(), |sym| (*sym.as_str()).to_string());
|
||||||
ItemType::StructField,
|
let id = cx.derive_id(format!("{}.{}", ItemType::StructField, field_name));
|
||||||
field.name.as_ref().unwrap()
|
|
||||||
));
|
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<span id=\"{id}\" class=\"{item_type} small-section-header\">\
|
"<span id=\"{id}\" class=\"{item_type} small-section-header\">\
|
||||||
|
@ -1199,7 +1199,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
|
||||||
</span>",
|
</span>",
|
||||||
item_type = ItemType::StructField,
|
item_type = ItemType::StructField,
|
||||||
id = id,
|
id = id,
|
||||||
name = field.name.as_ref().unwrap(),
|
name = field_name,
|
||||||
ty = ty.print(cx)
|
ty = ty.print(cx)
|
||||||
);
|
);
|
||||||
document(w, cx, field, Some(it));
|
document(w, cx, field, Some(it));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue