}
};
+ let mut have_impls = false;
let mut implementors = format!(r#"implementors["{}"] = ["#, krate.name);
for imp in imps {
// If the trait and implementation are in the same crate, then
// going on). If they're in different crates then the crate defining
// the trait will be interested in our implementation.
if imp.def_id.krate == did.krate { continue }
+ // If the implementation is from another crate then that crate
+ // should add it.
+ if !imp.def_id.is_local() { continue }
+ have_impls = true;
write!(implementors, "{},", as_json(&imp.impl_.to_string())).unwrap();
}
implementors.push_str("];");
+ // Only create a js file if we have impls to add to it. If the trait is
+ // documented locally though we always create the file to avoid dead
+ // links.
+ if !have_impls && !cache.paths.contains_key(&did) {
+ continue;
+ }
+
let mut mydst = dst.clone();
for part in &remote_path[..remote_path.len() - 1] {
mydst.push(part);
if !types.is_empty() {
write!(w, "
- <h2 id='associated-types' class='section-header'>
- <a href='#associated-types'>Associated Types</a>
+ <h2 id='associated-types' class='small-section-header'>
+ Associated Types<a href='#associated-types' class='anchor'></a>
</h2>
<div class='methods'>
")?;
if !consts.is_empty() {
write!(w, "
- <h2 id='associated-const' class='section-header'>
- <a href='#associated-const'>Associated Constants</a>
+ <h2 id='associated-const' class='small-section-header'>
+ Associated Constants<a href='#associated-const' class='anchor'></a>
</h2>
<div class='methods'>
")?;
// Output the documentation for each function individually
if !required.is_empty() {
write!(w, "
- <h2 id='required-methods' class='section-header'>
- <a href='#required-methods'>Required Methods</a>
+ <h2 id='required-methods' class='small-section-header'>
+ Required Methods<a href='#required-methods' class='anchor'></a>
</h2>
<div class='methods'>
")?;
}
if !provided.is_empty() {
write!(w, "
- <h2 id='provided-methods' class='section-header'>
- <a href='#provided-methods'>Provided Methods</a>
+ <h2 id='provided-methods' class='small-section-header'>
+ Provided Methods<a href='#provided-methods' class='anchor'></a>
</h2>
<div class='methods'>
")?;
let cache = cache();
write!(w, "
- <h2 id='implementors' class='section-header'>
- <a href='#implementors'>Implementors</a>
+ <h2 id='implementors' class='small-section-header'>
+ Implementors<a href='#implementors' class='anchor'></a>
</h2>
<ul class='item-list' id='implementors-list'>
")?;
}).peekable();
if let doctree::Plain = s.struct_type {
if fields.peek().is_some() {
- write!(w, "<h2 id='fields' class='fields section-header'>
- <a href='#fields'>Fields</a></h2>")?;
+ write!(w, "<h2 id='fields' class='fields small-section-header'>
+ Fields<a href='#fields' class='anchor'></a></h2>")?;
for (field, ty) in fields {
let id = derive_id(format!("{}.{}",
ItemType::StructField,
}
}).peekable();
if fields.peek().is_some() {
- write!(w, "<h2 id='fields' class='fields section-header'>
- <a href='#fields'>Fields</a></h2>")?;
+ write!(w, "<h2 id='fields' class='fields small-section-header'>
+ Fields<a href='#fields' class='anchor'></a></h2>")?;
for (field, ty) in fields {
write!(w, "<span id='{shortty}.{name}' class=\"{shortty}\"><code>{name}: {ty}</code>
</span>",
document(w, cx, it)?;
if !e.variants.is_empty() {
- write!(w, "<h2 id='variants' class='variants section-header'>
- <a href='#variants'>Variants</a></h2>\n")?;
+ write!(w, "<h2 id='variants' class='variants small-section-header'>
+ Variants<a href='#variants' class='anchor'></a></h2>\n")?;
for variant in &e.variants {
let id = derive_id(format!("{}.{}",
ItemType::Variant,
let render_mode = match what {
AssocItemRender::All => {
write!(w, "
- <h2 id='methods' class='section-header'>
- <a href='#methods'>Methods</a>
+ <h2 id='methods' class='small-section-header'>
+ Methods<a href='#methods' class='anchor'></a>
</h2>
")?;
RenderMode::Normal
}
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
write!(w, "
- <h2 id='deref-methods' class='section-header'>
- <a href='#deref-methods'>Methods from {}<Target = {}></a>
+ <h2 id='deref-methods' class='small-section-header'>
+ Methods from {}<Target = {}><a href='#deref-methods' class='anchor'></a>
</h2>
", trait_, type_)?;
RenderMode::ForDeref { mut_: deref_mut_ }
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut)?;
}
write!(w, "
- <h2 id='implementations' class='section-header'>
- <a href='#implementations'>Trait Implementations</a>
+ <h2 id='implementations' class='small-section-header'>
+ Trait Implementations<a href='#implementations' class='anchor'></a>
</h2>
")?;
for i in &traits {