Skip to content

rustdoc: Swap fields and variant documentations #123116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
rustdoc: Swap fields and variant documentations
Previously, the documentation for a variant appeared after the documentation
for each of its fields. This was inconsistent with structs and unions, and made
little sense on its own; fields are subordinate to variants and should
therefore appear later in the documentation.
  • Loading branch information
chloekek committed Mar 27, 2024
commit 1942f956a3d8c92fb33d6841b7410e65c33b60dd
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,8 @@ fn item_variants(
}
w.write_str("</h3></section>");

write!(w, "{}", document(cx, variant, Some(it), HeadingOffset::H4));

let heading_and_fields = match &variant_data.kind {
clean::VariantKind::Struct(s) => {
// If there is no field to display, no need to add the heading.
Expand Down Expand Up @@ -1789,8 +1791,6 @@ fn item_variants(
}
w.write_str("</div>");
}

write!(w, "{}", document(cx, variant, Some(it), HeadingOffset::H4));
}
write!(w, "</div>");
}
Expand Down