Show 'loading content' when loading content
This commit is contained in:
parent
e17518f65e
commit
b8c1726f26
2 changed files with 51 additions and 58 deletions
|
@ -3016,6 +3016,22 @@ fn item_trait(
|
||||||
// Trait documentation
|
// Trait documentation
|
||||||
document(w, cx, it)?;
|
document(w, cx, it)?;
|
||||||
|
|
||||||
|
fn write_small_section_header(
|
||||||
|
w: &mut fmt::Formatter,
|
||||||
|
id: &str,
|
||||||
|
title: &str,
|
||||||
|
extra_content: &str,
|
||||||
|
) -> fmt::Result {
|
||||||
|
write!(w, "
|
||||||
|
<h2 id='{0}' class='small-section-header'>\
|
||||||
|
{1}<a href='#{0}' class='anchor'></a>\
|
||||||
|
</h2>{2}", id, title, extra_content)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_loading_content(w: &mut fmt::Formatter, extra_content: &str) -> fmt::Result {
|
||||||
|
write!(w, "{}<span class='loading-content'>Loading content...</span>", extra_content)
|
||||||
|
}
|
||||||
|
|
||||||
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::Item)
|
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::Item)
|
||||||
-> fmt::Result {
|
-> fmt::Result {
|
||||||
let name = m.name.as_ref().unwrap();
|
let name = m.name.as_ref().unwrap();
|
||||||
|
@ -3036,74 +3052,45 @@ fn item_trait(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !types.is_empty() {
|
if !types.is_empty() {
|
||||||
write!(w, "
|
write_small_section_header(w, "associated-types", "Associated Types",
|
||||||
<h2 id='associated-types' class='small-section-header'>
|
"<div class='methods'>")?;
|
||||||
Associated Types<a href='#associated-types' class='anchor'></a>
|
|
||||||
</h2>
|
|
||||||
<div class='methods'>
|
|
||||||
")?;
|
|
||||||
for t in &types {
|
for t in &types {
|
||||||
trait_item(w, cx, *t, it)?;
|
trait_item(w, cx, *t, it)?;
|
||||||
}
|
}
|
||||||
write!(w, "</div>")?;
|
write_loading_content(w, "</div>")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !consts.is_empty() {
|
if !consts.is_empty() {
|
||||||
write!(w, "
|
write_small_section_header(w, "associated-const", "Associated Constants",
|
||||||
<h2 id='associated-const' class='small-section-header'>
|
"<div class='methods'>")?;
|
||||||
Associated Constants<a href='#associated-const' class='anchor'></a>
|
|
||||||
</h2>
|
|
||||||
<div class='methods'>
|
|
||||||
")?;
|
|
||||||
for t in &consts {
|
for t in &consts {
|
||||||
trait_item(w, cx, *t, it)?;
|
trait_item(w, cx, *t, it)?;
|
||||||
}
|
}
|
||||||
write!(w, "</div>")?;
|
write_loading_content(w, "</div>")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output the documentation for each function individually
|
// Output the documentation for each function individually
|
||||||
if !required.is_empty() {
|
if !required.is_empty() {
|
||||||
write!(w, "
|
write_small_section_header(w, "required-methods", "Required methods",
|
||||||
<h2 id='required-methods' class='small-section-header'>
|
"<div class='methods'>")?;
|
||||||
Required Methods<a href='#required-methods' class='anchor'></a>
|
|
||||||
</h2>
|
|
||||||
<div class='methods'>
|
|
||||||
")?;
|
|
||||||
for m in &required {
|
for m in &required {
|
||||||
trait_item(w, cx, *m, it)?;
|
trait_item(w, cx, *m, it)?;
|
||||||
}
|
}
|
||||||
write!(w, "</div>")?;
|
write_loading_content(w, "</div>")?;
|
||||||
}
|
}
|
||||||
if !provided.is_empty() {
|
if !provided.is_empty() {
|
||||||
write!(w, "
|
write_small_section_header(w, "provided-methods", "Provided methods",
|
||||||
<h2 id='provided-methods' class='small-section-header'>
|
"<div class='methods'>")?;
|
||||||
Provided Methods<a href='#provided-methods' class='anchor'></a>
|
|
||||||
</h2>
|
|
||||||
<div class='methods'>
|
|
||||||
")?;
|
|
||||||
for m in &provided {
|
for m in &provided {
|
||||||
trait_item(w, cx, *m, it)?;
|
trait_item(w, cx, *m, it)?;
|
||||||
}
|
}
|
||||||
write!(w, "</div>")?;
|
write_loading_content(w, "</div>")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are methods directly on this trait object, render them here.
|
// If there are methods directly on this trait object, render them here.
|
||||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)?;
|
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)?;
|
||||||
|
|
||||||
let cache = cache();
|
let cache = cache();
|
||||||
let impl_header = "\
|
|
||||||
<h2 id='implementors' class='small-section-header'>\
|
|
||||||
Implementors<a href='#implementors' class='anchor'></a>\
|
|
||||||
</h2>\
|
|
||||||
<div class='item-list' id='implementors-list'>\
|
|
||||||
";
|
|
||||||
|
|
||||||
let synthetic_impl_header = "\
|
|
||||||
<h2 id='synthetic-implementors' class='small-section-header'>\
|
|
||||||
Auto implementors<a href='#synthetic-implementors' class='anchor'></a>\
|
|
||||||
</h2>\
|
|
||||||
<div class='item-list' id='synthetic-implementors-list'>\
|
|
||||||
";
|
|
||||||
|
|
||||||
let mut synthetic_types = Vec::new();
|
let mut synthetic_types = Vec::new();
|
||||||
|
|
||||||
|
@ -3140,11 +3127,7 @@ fn item_trait(
|
||||||
concrete.sort_by(compare_impl);
|
concrete.sort_by(compare_impl);
|
||||||
|
|
||||||
if !foreign.is_empty() {
|
if !foreign.is_empty() {
|
||||||
write!(w, "
|
write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", "")?;
|
||||||
<h2 id='foreign-impls' class='small-section-header'>
|
|
||||||
Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
|
|
||||||
</h2>
|
|
||||||
")?;
|
|
||||||
|
|
||||||
for implementor in foreign {
|
for implementor in foreign {
|
||||||
let assoc_link = AssocItemLink::GotoSource(
|
let assoc_link = AssocItemLink::GotoSource(
|
||||||
|
@ -3155,33 +3138,38 @@ fn item_trait(
|
||||||
RenderMode::Normal, implementor.impl_item.stable_since(), false,
|
RenderMode::Normal, implementor.impl_item.stable_since(), false,
|
||||||
None)?;
|
None)?;
|
||||||
}
|
}
|
||||||
|
write_loading_content(w, "")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(w, "{}", impl_header)?;
|
write_small_section_header(w, "implementors", "Implementors",
|
||||||
|
"<div class='item-list' id='implementors-list'>")?;
|
||||||
for implementor in concrete {
|
for implementor in concrete {
|
||||||
render_implementor(cx, implementor, w, &implementor_dups)?;
|
render_implementor(cx, implementor, w, &implementor_dups)?;
|
||||||
}
|
}
|
||||||
write!(w, "</div>")?;
|
write_loading_content(w, "</div>")?;
|
||||||
|
|
||||||
if t.auto {
|
if t.auto {
|
||||||
write!(w, "{}", synthetic_impl_header)?;
|
write_small_section_header(w, "synthetic-implementors", "Auto implementors",
|
||||||
|
"<div class='item-list' id='synthetic-implementors-list'>")?;
|
||||||
for implementor in synthetic {
|
for implementor in synthetic {
|
||||||
synthetic_types.extend(
|
synthetic_types.extend(
|
||||||
collect_paths_for_type(implementor.inner_impl().for_.clone())
|
collect_paths_for_type(implementor.inner_impl().for_.clone())
|
||||||
);
|
);
|
||||||
render_implementor(cx, implementor, w, &implementor_dups)?;
|
render_implementor(cx, implementor, w, &implementor_dups)?;
|
||||||
}
|
}
|
||||||
write!(w, "</div>")?;
|
write_loading_content(w, "</div>")?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// even without any implementations to write in, we still want the heading and list, so the
|
// even without any implementations to write in, we still want the heading and list, so the
|
||||||
// implementors javascript file pulled in below has somewhere to write the impls into
|
// implementors javascript file pulled in below has somewhere to write the impls into
|
||||||
write!(w, "{}", impl_header)?;
|
write_small_section_header(w, "implementors", "Implementors",
|
||||||
write!(w, "</div>")?;
|
"<div class='item-list' id='implementors-list'>")?;
|
||||||
|
write_loading_content(w, "</div>")?;
|
||||||
|
|
||||||
if t.auto {
|
if t.auto {
|
||||||
write!(w, "{}", synthetic_impl_header)?;
|
write_small_section_header(w, "synthetic-implementors", "Auto implementors",
|
||||||
write!(w, "</div>")?;
|
"<div class='item-list' id='synthetic-implementors-list'>")?;
|
||||||
|
write_loading_content(w, "</div>")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
|
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
|
||||||
|
|
|
@ -1961,7 +1961,7 @@ if (!DOMTokenList.prototype.remove) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var relatedDoc;
|
var relatedDoc;
|
||||||
var action;
|
var action = mode;
|
||||||
if (hasClass(toggle.parentNode, "impl") === false) {
|
if (hasClass(toggle.parentNode, "impl") === false) {
|
||||||
relatedDoc = toggle.parentNode.nextElementSibling;
|
relatedDoc = toggle.parentNode.nextElementSibling;
|
||||||
if (hasClass(relatedDoc, "stability")) {
|
if (hasClass(relatedDoc, "stability")) {
|
||||||
|
@ -1997,7 +1997,7 @@ if (!DOMTokenList.prototype.remove) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!relatedDoc && hasClass(docblock, "docblock") === false) ||
|
if ((!relatedDoc && hasClass(docblock, "docblock") === false) ||
|
||||||
(pageId && relatedDoc.getElementById(pageId))) {
|
(pageId && document.getElementById(pageId))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,7 +2026,7 @@ if (!DOMTokenList.prototype.remove) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function collapser(e) {
|
function collapser(e, collapse) {
|
||||||
// inherent impl ids are like "impl" or impl-<number>'.
|
// inherent impl ids are like "impl" or impl-<number>'.
|
||||||
// they will never be hidden by default.
|
// they will never be hidden by default.
|
||||||
var n = e.parentElement;
|
var n = e.parentElement;
|
||||||
|
@ -2045,7 +2045,9 @@ if (!DOMTokenList.prototype.remove) {
|
||||||
var impl_list = document.getElementById("implementations-list");
|
var impl_list = document.getElementById("implementations-list");
|
||||||
|
|
||||||
if (impl_list !== null) {
|
if (impl_list !== null) {
|
||||||
onEachLazy(impl_list.getElementsByClassName("collapse-toggle"), collapser);
|
onEachLazy(impl_list.getElementsByClassName("collapse-toggle"), function(e) {
|
||||||
|
collapser(e, collapse);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2415,6 +2417,9 @@ if (!DOMTokenList.prototype.remove) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (main) {
|
if (main) {
|
||||||
|
onEachLazy(main.getElementsByClassName("loading-content"), function(e) {
|
||||||
|
e.remove();
|
||||||
|
});
|
||||||
onEachLazy(main.childNodes, function(e) {
|
onEachLazy(main.childNodes, function(e) {
|
||||||
if (e.tagName === "H2" || e.tagName === "H3") {
|
if (e.tagName === "H2" || e.tagName === "H3") {
|
||||||
e.nextElementSibling.style.display = "block";
|
e.nextElementSibling.style.display = "block";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue