Skip to content

Rustdoc cleanup #85175

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 3 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
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
23 changes: 8 additions & 15 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,6 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
)
}

fn write_loading_content(w: &mut Buffer, extra_content: &str) {
write!(w, "{}<span class=\"loading-content\">Loading content...</span>", extra_content)
}

fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item) {
let name = m.name.as_ref().unwrap();
info!("Documenting {} on {:?}", name, t.name);
Expand All @@ -601,7 +597,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
for t in types {
trait_item(w, cx, t, it);
}
write_loading_content(w, "</div>");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The </div> itself still need to be there, doesn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, good catch!

w.write_str("</div>");
}

if !consts.is_empty() {
Expand All @@ -614,7 +610,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
for t in consts {
trait_item(w, cx, t, it);
}
write_loading_content(w, "</div>");
w.write_str("</div>");
}

// Output the documentation for each function individually
Expand All @@ -628,7 +624,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
for m in required {
trait_item(w, cx, m, it);
}
write_loading_content(w, "</div>");
w.write_str("</div>");
}
if !provided.is_empty() {
write_small_section_header(
Expand All @@ -640,7 +636,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
for m in provided {
trait_item(w, cx, m, it);
}
write_loading_content(w, "</div>");
w.write_str("</div>");
}

// If there are methods directly on this trait object, render them here.
Expand Down Expand Up @@ -703,7 +699,6 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
&[],
);
}
write_loading_content(w, "");
}

write_small_section_header(
Expand All @@ -715,7 +710,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
for implementor in concrete {
render_implementor(cx, implementor, it, w, &implementor_dups, &[]);
}
write_loading_content(w, "</div>");
w.write_str("</div>");

if t.is_auto {
write_small_section_header(
Expand All @@ -734,7 +729,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
&collect_paths_for_type(implementor.inner_impl().for_.clone(), &cx.cache),
);
}
write_loading_content(w, "</div>");
w.write_str("</div>");
}
} else {
// even without any implementations to write in, we still want the heading and list, so the
Expand All @@ -743,18 +738,16 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
w,
"implementors",
"Implementors",
"<div class=\"item-list\" id=\"implementors-list\">",
"<div class=\"item-list\" id=\"implementors-list\"></div>",
);
write_loading_content(w, "</div>");

if t.is_auto {
write_small_section_header(
w,
"synthetic-implementors",
"Auto implementors",
"<div class=\"item-list\" id=\"synthetic-implementors-list\">",
"<div class=\"item-list\" id=\"synthetic-implementors-list\"></div>",
);
write_loading_content(w, "</div>");
}
}

Expand Down
Loading