rustdoc: Pass the Context down to short_stability()
This commit is contained in:
parent
440c0f07c3
commit
b31038764d
1 changed files with 58 additions and 56 deletions
|
@ -1494,16 +1494,16 @@ impl<'a> fmt::Display for Item<'a> {
|
||||||
item_module(fmt, self.cx, self.item, &m.items)
|
item_module(fmt, self.cx, self.item, &m.items)
|
||||||
}
|
}
|
||||||
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
|
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
|
||||||
item_function(fmt, self.item, f),
|
item_function(fmt, self.cx, self.item, f),
|
||||||
clean::TraitItem(ref t) => item_trait(fmt, self.cx, self.item, t),
|
clean::TraitItem(ref t) => item_trait(fmt, self.cx, self.item, t),
|
||||||
clean::StructItem(ref s) => item_struct(fmt, self.item, s),
|
clean::StructItem(ref s) => item_struct(fmt, self.cx, self.item, s),
|
||||||
clean::EnumItem(ref e) => item_enum(fmt, self.item, e),
|
clean::EnumItem(ref e) => item_enum(fmt, self.cx, self.item, e),
|
||||||
clean::TypedefItem(ref t, _) => item_typedef(fmt, self.item, t),
|
clean::TypedefItem(ref t, _) => item_typedef(fmt, self.cx, self.item, t),
|
||||||
clean::MacroItem(ref m) => item_macro(fmt, self.item, m),
|
clean::MacroItem(ref m) => item_macro(fmt, self.cx, self.item, m),
|
||||||
clean::PrimitiveItem(ref p) => item_primitive(fmt, self.item, p),
|
clean::PrimitiveItem(ref p) => item_primitive(fmt, self.cx, self.item, p),
|
||||||
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) =>
|
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) =>
|
||||||
item_static(fmt, self.item, i),
|
item_static(fmt, self.cx, self.item, i),
|
||||||
clean::ConstantItem(ref c) => item_constant(fmt, self.item, c),
|
clean::ConstantItem(ref c) => item_constant(fmt, self.cx, self.item, c),
|
||||||
_ => Ok(())
|
_ => Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1546,8 +1546,8 @@ fn plain_summary_line(s: Option<&str>) -> String {
|
||||||
markdown::plain_summary_line(&line[..])
|
markdown::plain_summary_line(&line[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn document(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
|
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
|
||||||
if let Some(s) = short_stability(item, true) {
|
if let Some(s) = short_stability(item, cx, true) {
|
||||||
try!(write!(w, "<div class='stability'>{}</div>", s));
|
try!(write!(w, "<div class='stability'>{}</div>", s));
|
||||||
}
|
}
|
||||||
if let Some(s) = item.doc_value() {
|
if let Some(s) = item.doc_value() {
|
||||||
|
@ -1558,7 +1558,7 @@ fn document(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
|
||||||
|
|
||||||
fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
|
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
|
||||||
try!(document(w, item));
|
try!(document(w, cx, item));
|
||||||
|
|
||||||
let mut indices = (0..items.len()).filter(|i| {
|
let mut indices = (0..items.len()).filter(|i| {
|
||||||
!cx.ignore_private_item(&items[*i])
|
!cx.ignore_private_item(&items[*i])
|
||||||
|
@ -1666,7 +1666,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
if myitem.name.is_none() { continue }
|
if myitem.name.is_none() { continue }
|
||||||
let stab_docs = if let Some(s) = short_stability(myitem, false) {
|
let stab_docs = if let Some(s) = short_stability(myitem, cx, false) {
|
||||||
format!("[{}]", s)
|
format!("[{}]", s)
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
|
@ -1694,7 +1694,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
write!(w, "</table>")
|
write!(w, "</table>")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn short_stability(item: &clean::Item, show_reason: bool) -> Option<String> {
|
fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Option<String> {
|
||||||
item.stability.as_ref().and_then(|stab| {
|
item.stability.as_ref().and_then(|stab| {
|
||||||
let reason = if show_reason && !stab.reason.is_empty() {
|
let reason = if show_reason && !stab.reason.is_empty() {
|
||||||
format!(": {}", stab.reason)
|
format!(": {}", stab.reason)
|
||||||
|
@ -1729,7 +1729,7 @@ impl<'a> fmt::Display for Initializer<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_constant(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_constant(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
c: &clean::Constant) -> fmt::Result {
|
c: &clean::Constant) -> fmt::Result {
|
||||||
try!(write!(w, "<pre class='rust const'>{vis}const \
|
try!(write!(w, "<pre class='rust const'>{vis}const \
|
||||||
{name}: {typ}{init}</pre>",
|
{name}: {typ}{init}</pre>",
|
||||||
|
@ -1737,10 +1737,10 @@ fn item_constant(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
name = it.name.as_ref().unwrap(),
|
name = it.name.as_ref().unwrap(),
|
||||||
typ = c.type_,
|
typ = c.type_,
|
||||||
init = Initializer(&c.expr)));
|
init = Initializer(&c.expr)));
|
||||||
document(w, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_static(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
s: &clean::Static) -> fmt::Result {
|
s: &clean::Static) -> fmt::Result {
|
||||||
try!(write!(w, "<pre class='rust static'>{vis}static {mutability}\
|
try!(write!(w, "<pre class='rust static'>{vis}static {mutability}\
|
||||||
{name}: {typ}{init}</pre>",
|
{name}: {typ}{init}</pre>",
|
||||||
|
@ -1749,10 +1749,10 @@ fn item_static(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
name = it.name.as_ref().unwrap(),
|
name = it.name.as_ref().unwrap(),
|
||||||
typ = s.type_,
|
typ = s.type_,
|
||||||
init = Initializer(&s.expr)));
|
init = Initializer(&s.expr)));
|
||||||
document(w, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_function(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
f: &clean::Function) -> fmt::Result {
|
f: &clean::Function) -> fmt::Result {
|
||||||
try!(write!(w, "<pre class='rust fn'>{vis}{unsafety}{abi}{constness}fn \
|
try!(write!(w, "<pre class='rust fn'>{vis}{unsafety}{abi}{constness}fn \
|
||||||
{name}{generics}{decl}{where_clause}</pre>",
|
{name}{generics}{decl}{where_clause}</pre>",
|
||||||
|
@ -1764,7 +1764,7 @@ fn item_function(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
generics = f.generics,
|
generics = f.generics,
|
||||||
where_clause = WhereClause(&f.generics),
|
where_clause = WhereClause(&f.generics),
|
||||||
decl = f.decl));
|
decl = f.decl));
|
||||||
document(w, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
|
@ -1841,9 +1841,9 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
try!(write!(w, "</pre>"));
|
try!(write!(w, "</pre>"));
|
||||||
|
|
||||||
// Trait documentation
|
// Trait documentation
|
||||||
try!(document(w, it));
|
try!(document(w, cx, it));
|
||||||
|
|
||||||
fn trait_item(w: &mut fmt::Formatter, m: &clean::Item)
|
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item)
|
||||||
-> fmt::Result {
|
-> fmt::Result {
|
||||||
try!(write!(w, "<h3 id='{ty}.{name}' class='method stab {stab}'><code>",
|
try!(write!(w, "<h3 id='{ty}.{name}' class='method stab {stab}'><code>",
|
||||||
ty = shortty(m),
|
ty = shortty(m),
|
||||||
|
@ -1851,7 +1851,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
stab = m.stability_class()));
|
stab = m.stability_class()));
|
||||||
try!(render_assoc_item(w, m, AssocItemLink::Anchor));
|
try!(render_assoc_item(w, m, AssocItemLink::Anchor));
|
||||||
try!(write!(w, "</code></h3>"));
|
try!(write!(w, "</code></h3>"));
|
||||||
try!(document(w, m));
|
try!(document(w, cx, m));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1861,7 +1861,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
<div class='methods'>
|
<div class='methods'>
|
||||||
"));
|
"));
|
||||||
for t in &types {
|
for t in &types {
|
||||||
try!(trait_item(w, *t));
|
try!(trait_item(w, cx, *t));
|
||||||
}
|
}
|
||||||
try!(write!(w, "</div>"));
|
try!(write!(w, "</div>"));
|
||||||
}
|
}
|
||||||
|
@ -1872,7 +1872,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
<div class='methods'>
|
<div class='methods'>
|
||||||
"));
|
"));
|
||||||
for t in &consts {
|
for t in &consts {
|
||||||
try!(trait_item(w, *t));
|
try!(trait_item(w, cx, *t));
|
||||||
}
|
}
|
||||||
try!(write!(w, "</div>"));
|
try!(write!(w, "</div>"));
|
||||||
}
|
}
|
||||||
|
@ -1884,7 +1884,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
<div class='methods'>
|
<div class='methods'>
|
||||||
"));
|
"));
|
||||||
for m in &required {
|
for m in &required {
|
||||||
try!(trait_item(w, *m));
|
try!(trait_item(w, cx, *m));
|
||||||
}
|
}
|
||||||
try!(write!(w, "</div>"));
|
try!(write!(w, "</div>"));
|
||||||
}
|
}
|
||||||
|
@ -1894,13 +1894,13 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
<div class='methods'>
|
<div class='methods'>
|
||||||
"));
|
"));
|
||||||
for m in &provided {
|
for m in &provided {
|
||||||
try!(trait_item(w, *m));
|
try!(trait_item(w, cx, *m));
|
||||||
}
|
}
|
||||||
try!(write!(w, "</div>"));
|
try!(write!(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.
|
||||||
try!(render_assoc_items(w, it.def_id, AssocItemRender::All));
|
try!(render_assoc_items(w, cx, it.def_id, AssocItemRender::All));
|
||||||
|
|
||||||
let cache = cache();
|
let cache = cache();
|
||||||
try!(write!(w, "
|
try!(write!(w, "
|
||||||
|
@ -2012,7 +2012,7 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
s: &clean::Struct) -> fmt::Result {
|
s: &clean::Struct) -> fmt::Result {
|
||||||
try!(write!(w, "<pre class='rust struct'>"));
|
try!(write!(w, "<pre class='rust struct'>"));
|
||||||
try!(render_attributes(w, it));
|
try!(render_attributes(w, it));
|
||||||
|
@ -2025,7 +2025,7 @@ fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
true));
|
true));
|
||||||
try!(write!(w, "</pre>"));
|
try!(write!(w, "</pre>"));
|
||||||
|
|
||||||
try!(document(w, it));
|
try!(document(w, cx, it));
|
||||||
let mut fields = s.fields.iter().filter(|f| {
|
let mut fields = s.fields.iter().filter(|f| {
|
||||||
match f.inner {
|
match f.inner {
|
||||||
clean::StructFieldItem(clean::HiddenStructField) => false,
|
clean::StructFieldItem(clean::HiddenStructField) => false,
|
||||||
|
@ -2042,16 +2042,16 @@ fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
<code>{name}</code></td><td>",
|
<code>{name}</code></td><td>",
|
||||||
stab = field.stability_class(),
|
stab = field.stability_class(),
|
||||||
name = field.name.as_ref().unwrap()));
|
name = field.name.as_ref().unwrap()));
|
||||||
try!(document(w, field));
|
try!(document(w, cx, field));
|
||||||
try!(write!(w, "</td></tr>"));
|
try!(write!(w, "</td></tr>"));
|
||||||
}
|
}
|
||||||
try!(write!(w, "</table>"));
|
try!(write!(w, "</table>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render_assoc_items(w, it.def_id, AssocItemRender::All)
|
render_assoc_items(w, cx, it.def_id, AssocItemRender::All)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
e: &clean::Enum) -> fmt::Result {
|
e: &clean::Enum) -> fmt::Result {
|
||||||
try!(write!(w, "<pre class='rust enum'>"));
|
try!(write!(w, "<pre class='rust enum'>"));
|
||||||
try!(render_attributes(w, it));
|
try!(render_attributes(w, it));
|
||||||
|
@ -2104,13 +2104,13 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
}
|
}
|
||||||
try!(write!(w, "</pre>"));
|
try!(write!(w, "</pre>"));
|
||||||
|
|
||||||
try!(document(w, it));
|
try!(document(w, cx, it));
|
||||||
if !e.variants.is_empty() {
|
if !e.variants.is_empty() {
|
||||||
try!(write!(w, "<h2 class='variants'>Variants</h2>\n<table>"));
|
try!(write!(w, "<h2 class='variants'>Variants</h2>\n<table>"));
|
||||||
for variant in &e.variants {
|
for variant in &e.variants {
|
||||||
try!(write!(w, "<tr><td id='variant.{name}'><code>{name}</code></td><td>",
|
try!(write!(w, "<tr><td id='variant.{name}'><code>{name}</code></td><td>",
|
||||||
name = variant.name.as_ref().unwrap()));
|
name = variant.name.as_ref().unwrap()));
|
||||||
try!(document(w, variant));
|
try!(document(w, cx, variant));
|
||||||
match variant.inner {
|
match variant.inner {
|
||||||
clean::VariantItem(ref var) => {
|
clean::VariantItem(ref var) => {
|
||||||
match var.kind {
|
match var.kind {
|
||||||
|
@ -2132,7 +2132,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
<code>{f}</code></td><td>",
|
<code>{f}</code></td><td>",
|
||||||
v = variant.name.as_ref().unwrap(),
|
v = variant.name.as_ref().unwrap(),
|
||||||
f = field.name.as_ref().unwrap()));
|
f = field.name.as_ref().unwrap()));
|
||||||
try!(document(w, field));
|
try!(document(w, cx, field));
|
||||||
try!(write!(w, "</td></tr>"));
|
try!(write!(w, "</td></tr>"));
|
||||||
}
|
}
|
||||||
try!(write!(w, "</table>"));
|
try!(write!(w, "</table>"));
|
||||||
|
@ -2147,7 +2147,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
try!(write!(w, "</table>"));
|
try!(write!(w, "</table>"));
|
||||||
|
|
||||||
}
|
}
|
||||||
try!(render_assoc_items(w, it.def_id, AssocItemRender::All));
|
try!(render_assoc_items(w, cx, it.def_id, AssocItemRender::All));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2242,6 +2242,7 @@ enum AssocItemRender<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_assoc_items(w: &mut fmt::Formatter,
|
fn render_assoc_items(w: &mut fmt::Formatter,
|
||||||
|
cx: &Context,
|
||||||
it: ast::DefId,
|
it: ast::DefId,
|
||||||
what: AssocItemRender) -> fmt::Result {
|
what: AssocItemRender) -> fmt::Result {
|
||||||
let c = cache();
|
let c = cache();
|
||||||
|
@ -2265,7 +2266,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for i in &non_trait {
|
for i in &non_trait {
|
||||||
try!(render_impl(w, i, AssocItemLink::Anchor, render_header));
|
try!(render_impl(w, cx, i, AssocItemLink::Anchor, render_header));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let AssocItemRender::DerefFor { .. } = what {
|
if let AssocItemRender::DerefFor { .. } = what {
|
||||||
|
@ -2281,7 +2282,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if let Some(impl_) = deref_impl {
|
if let Some(impl_) = deref_impl {
|
||||||
try!(render_deref_methods(w, impl_));
|
try!(render_deref_methods(w, cx, impl_));
|
||||||
}
|
}
|
||||||
try!(write!(w, "<h2 id='implementations'>Trait \
|
try!(write!(w, "<h2 id='implementations'>Trait \
|
||||||
Implementations</h2>"));
|
Implementations</h2>"));
|
||||||
|
@ -2290,7 +2291,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||||
});
|
});
|
||||||
for i in &manual {
|
for i in &manual {
|
||||||
let did = i.trait_did().unwrap();
|
let did = i.trait_did().unwrap();
|
||||||
try!(render_impl(w, i, AssocItemLink::GotoSource(did), true));
|
try!(render_impl(w, cx, i, AssocItemLink::GotoSource(did), true));
|
||||||
}
|
}
|
||||||
if !derived.is_empty() {
|
if !derived.is_empty() {
|
||||||
try!(write!(w, "<h3 id='derived_implementations'>\
|
try!(write!(w, "<h3 id='derived_implementations'>\
|
||||||
|
@ -2298,14 +2299,14 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||||
</h3>"));
|
</h3>"));
|
||||||
for i in &derived {
|
for i in &derived {
|
||||||
let did = i.trait_did().unwrap();
|
let did = i.trait_did().unwrap();
|
||||||
try!(render_impl(w, i, AssocItemLink::GotoSource(did), true));
|
try!(render_impl(w, cx, i, AssocItemLink::GotoSource(did), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_deref_methods(w: &mut fmt::Formatter, impl_: &Impl) -> fmt::Result {
|
fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl) -> fmt::Result {
|
||||||
let deref_type = impl_.impl_.trait_.as_ref().unwrap();
|
let deref_type = impl_.impl_.trait_.as_ref().unwrap();
|
||||||
let target = impl_.impl_.items.iter().filter_map(|item| {
|
let target = impl_.impl_.items.iter().filter_map(|item| {
|
||||||
match item.inner {
|
match item.inner {
|
||||||
|
@ -2315,12 +2316,12 @@ fn render_deref_methods(w: &mut fmt::Formatter, impl_: &Impl) -> fmt::Result {
|
||||||
}).next().expect("Expected associated type binding");
|
}).next().expect("Expected associated type binding");
|
||||||
let what = AssocItemRender::DerefFor { trait_: deref_type, type_: target };
|
let what = AssocItemRender::DerefFor { trait_: deref_type, type_: target };
|
||||||
match *target {
|
match *target {
|
||||||
clean::ResolvedPath { did, .. } => render_assoc_items(w, did, what),
|
clean::ResolvedPath { did, .. } => render_assoc_items(w, cx, did, what),
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(prim) = target.primitive_type() {
|
if let Some(prim) = target.primitive_type() {
|
||||||
if let Some(c) = cache().primitive_locations.get(&prim) {
|
if let Some(c) = cache().primitive_locations.get(&prim) {
|
||||||
let did = ast::DefId { krate: *c, node: prim.to_node_id() };
|
let did = ast::DefId { krate: *c, node: prim.to_node_id() };
|
||||||
try!(render_assoc_items(w, did, what));
|
try!(render_assoc_items(w, cx, did, what));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2331,7 +2332,7 @@ fn render_deref_methods(w: &mut fmt::Formatter, impl_: &Impl) -> fmt::Result {
|
||||||
// Render_header is false when we are rendering a `Deref` impl and true
|
// Render_header is false when we are rendering a `Deref` impl and true
|
||||||
// otherwise. If render_header is false, we will avoid rendering static
|
// otherwise. If render_header is false, we will avoid rendering static
|
||||||
// methods, since they are not accessible for the type implementing `Deref`
|
// methods, since they are not accessible for the type implementing `Deref`
|
||||||
fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink,
|
||||||
render_header: bool) -> fmt::Result {
|
render_header: bool) -> fmt::Result {
|
||||||
if render_header {
|
if render_header {
|
||||||
try!(write!(w, "<h3 class='impl'><code>{}</code></h3>", i.impl_));
|
try!(write!(w, "<h3 class='impl'><code>{}</code></h3>", i.impl_));
|
||||||
|
@ -2340,7 +2341,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn doctraititem(w: &mut fmt::Formatter, item: &clean::Item,
|
fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
|
||||||
link: AssocItemLink, render_static: bool) -> fmt::Result {
|
link: AssocItemLink, render_static: bool) -> fmt::Result {
|
||||||
match item.inner {
|
match item.inner {
|
||||||
clean::MethodItem(..) | clean::TyMethodItem(..) => {
|
clean::MethodItem(..) | clean::TyMethodItem(..) => {
|
||||||
|
@ -2390,7 +2391,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
||||||
if is_static_method(item) && !render_static {
|
if is_static_method(item) && !render_static {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
document(w, item)
|
document(w, cx, item)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2407,10 +2408,11 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
||||||
|
|
||||||
try!(write!(w, "<div class='impl-items'>"));
|
try!(write!(w, "<div class='impl-items'>"));
|
||||||
for trait_item in &i.impl_.items {
|
for trait_item in &i.impl_.items {
|
||||||
try!(doctraititem(w, trait_item, link, render_header));
|
try!(doctraititem(w, cx, trait_item, link, render_header));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_default_items(w: &mut fmt::Formatter,
|
fn render_default_items(w: &mut fmt::Formatter,
|
||||||
|
cx: &Context,
|
||||||
did: ast::DefId,
|
did: ast::DefId,
|
||||||
t: &clean::Trait,
|
t: &clean::Trait,
|
||||||
i: &clean::Impl,
|
i: &clean::Impl,
|
||||||
|
@ -2422,7 +2424,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(doctraititem(w, trait_item, AssocItemLink::GotoSource(did), render_static));
|
try!(doctraititem(w, cx, trait_item, AssocItemLink::GotoSource(did), render_static));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -2433,7 +2435,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
||||||
// for them work.
|
// for them work.
|
||||||
if let Some(clean::ResolvedPath { did, .. }) = i.impl_.trait_ {
|
if let Some(clean::ResolvedPath { did, .. }) = i.impl_.trait_ {
|
||||||
if let Some(t) = cache().traits.get(&did) {
|
if let Some(t) = cache().traits.get(&did) {
|
||||||
try!(render_default_items(w, did, t, &i.impl_, render_header));
|
try!(render_default_items(w, cx, did, t, &i.impl_, render_header));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2441,7 +2443,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_typedef(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
t: &clean::Typedef) -> fmt::Result {
|
t: &clean::Typedef) -> fmt::Result {
|
||||||
try!(write!(w, "<pre class='rust typedef'>type {}{}{where_clause} = {type_};</pre>",
|
try!(write!(w, "<pre class='rust typedef'>type {}{}{where_clause} = {type_};</pre>",
|
||||||
it.name.as_ref().unwrap(),
|
it.name.as_ref().unwrap(),
|
||||||
|
@ -2449,7 +2451,7 @@ fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
where_clause = WhereClause(&t.generics),
|
where_clause = WhereClause(&t.generics),
|
||||||
type_ = t.type_));
|
type_ = t.type_));
|
||||||
|
|
||||||
document(w, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for Sidebar<'a> {
|
impl<'a> fmt::Display for Sidebar<'a> {
|
||||||
|
@ -2520,19 +2522,19 @@ impl<'a> fmt::Display for Source<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_macro(w: &mut fmt::Formatter, it: &clean::Item,
|
fn item_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
t: &clean::Macro) -> fmt::Result {
|
t: &clean::Macro) -> fmt::Result {
|
||||||
try!(w.write_str(&highlight::highlight(&t.source,
|
try!(w.write_str(&highlight::highlight(&t.source,
|
||||||
Some("macro"),
|
Some("macro"),
|
||||||
None)));
|
None)));
|
||||||
document(w, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_primitive(w: &mut fmt::Formatter,
|
fn item_primitive(w: &mut fmt::Formatter, cx: &Context,
|
||||||
it: &clean::Item,
|
it: &clean::Item,
|
||||||
_p: &clean::PrimitiveType) -> fmt::Result {
|
_p: &clean::PrimitiveType) -> fmt::Result {
|
||||||
try!(document(w, it));
|
try!(document(w, cx, it));
|
||||||
render_assoc_items(w, it.def_id, AssocItemRender::All)
|
render_assoc_items(w, cx, it.def_id, AssocItemRender::All)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_basic_keywords() -> &'static str {
|
fn get_basic_keywords() -> &'static str {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue