rustdoc: apply proper indent when where clauses aren't on their own line
This commit is contained in:
@@ -50,7 +50,7 @@ pub struct MutableSpace(pub clean::Mutability);
|
|||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct RawMutableSpace(pub clean::Mutability);
|
pub struct RawMutableSpace(pub clean::Mutability);
|
||||||
/// Wrapper struct for emitting a where clause from Generics.
|
/// Wrapper struct for emitting a where clause from Generics.
|
||||||
pub struct WhereClause<'a>(pub &'a clean::Generics);
|
pub struct WhereClause<'a>(pub &'a clean::Generics, pub String);
|
||||||
/// Wrapper struct for emitting type parameter bounds.
|
/// Wrapper struct for emitting type parameter bounds.
|
||||||
pub struct TyParamBounds<'a>(pub &'a [clean::TyParamBound]);
|
pub struct TyParamBounds<'a>(pub &'a [clean::TyParamBound]);
|
||||||
/// Wrapper struct for emitting a comma-separated list of items
|
/// Wrapper struct for emitting a comma-separated list of items
|
||||||
@@ -157,7 +157,7 @@ impl fmt::Display for clean::Generics {
|
|||||||
|
|
||||||
impl<'a> fmt::Display for WhereClause<'a> {
|
impl<'a> fmt::Display for WhereClause<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let &WhereClause(gens) = self;
|
let &WhereClause(gens, ref pad) = self;
|
||||||
if gens.where_predicates.is_empty() {
|
if gens.where_predicates.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -207,8 +207,8 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
|||||||
if !f.alternate() {
|
if !f.alternate() {
|
||||||
clause.push_str("</span>");
|
clause.push_str("</span>");
|
||||||
let plain = format!("{:#}", self);
|
let plain = format!("{:#}", self);
|
||||||
if plain.len() > 80 {
|
if plain.len() + pad.len() > 80 {
|
||||||
let padding = repeat(" ").take(8).collect::<String>();
|
let padding = repeat(" ").take(pad.len() + 6).collect::<String>();
|
||||||
clause = clause.replace("<br>", &format!("<br>{}", padding));
|
clause = clause.replace("<br>", &format!("<br>{}", padding));
|
||||||
} else {
|
} else {
|
||||||
clause = clause.replace("<br>", " ");
|
clause = clause.replace("<br>", " ");
|
||||||
@@ -730,30 +730,44 @@ impl fmt::Display for clean::Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_impl(i: &clean::Impl, f: &mut fmt::Formatter, link_trait: bool) -> fmt::Result {
|
fn fmt_impl(i: &clean::Impl, f: &mut fmt::Formatter, link_trait: bool) -> fmt::Result {
|
||||||
|
let mut plain = String::new();
|
||||||
|
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "impl{:#} ", i.generics)?;
|
write!(f, "impl{:#} ", i.generics)?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "impl{} ", i.generics)?;
|
write!(f, "impl{} ", i.generics)?;
|
||||||
}
|
}
|
||||||
|
plain.push_str(&format!("impl{:#} ", i.generics));
|
||||||
|
|
||||||
if let Some(ref ty) = i.trait_ {
|
if let Some(ref ty) = i.trait_ {
|
||||||
write!(f, "{}",
|
if i.polarity == Some(clean::ImplPolarity::Negative) {
|
||||||
if i.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" })?;
|
write!(f, "!")?;
|
||||||
|
plain.push_str("!");
|
||||||
|
}
|
||||||
|
|
||||||
if link_trait {
|
if link_trait {
|
||||||
fmt::Display::fmt(ty, f)?;
|
fmt::Display::fmt(ty, f)?;
|
||||||
|
plain.push_str(&format!("{:#}", ty));
|
||||||
} else {
|
} else {
|
||||||
match *ty {
|
match *ty {
|
||||||
clean::ResolvedPath{ typarams: None, ref path, is_generic: false, .. } => {
|
clean::ResolvedPath{ typarams: None, ref path, is_generic: false, .. } => {
|
||||||
let last = path.segments.last().unwrap();
|
let last = path.segments.last().unwrap();
|
||||||
fmt::Display::fmt(&last.name, f)?;
|
fmt::Display::fmt(&last.name, f)?;
|
||||||
fmt::Display::fmt(&last.params, f)?;
|
fmt::Display::fmt(&last.params, f)?;
|
||||||
|
plain.push_str(&format!("{:#}{:#}", last.name, last.params));
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, " for ")?;
|
write!(f, " for ")?;
|
||||||
|
plain.push_str(" for ");
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt::Display::fmt(&i.for_, f)?;
|
fmt::Display::fmt(&i.for_, f)?;
|
||||||
fmt::Display::fmt(&WhereClause(&i.generics), f)?;
|
plain.push_str(&format!("{:#}", i.for_));
|
||||||
|
|
||||||
|
let pad = repeat(" ").take(plain.len() + 1).collect::<String>();
|
||||||
|
fmt::Display::fmt(&WhereClause(&i.generics, pad), f)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,8 +913,12 @@ impl<'a> fmt::Display for Method<'a> {
|
|||||||
} else {
|
} else {
|
||||||
output = output.replace("<br>", "");
|
output = output.replace("<br>", "");
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{}", output.replace("<br>", "\n"))
|
||||||
|
} else {
|
||||||
write!(f, "{}", output)
|
write!(f, "{}", output)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for VisSpace<'a> {
|
impl<'a> fmt::Display for VisSpace<'a> {
|
||||||
|
|||||||
@@ -1983,7 +1983,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
abi = AbiSpace(f.abi),
|
abi = AbiSpace(f.abi),
|
||||||
name = it.name.as_ref().unwrap(),
|
name = it.name.as_ref().unwrap(),
|
||||||
generics = f.generics,
|
generics = f.generics,
|
||||||
where_clause = WhereClause(&f.generics),
|
where_clause = WhereClause(&f.generics, " ".to_string()),
|
||||||
decl = Method(&f.decl, &indent))?;
|
decl = Method(&f.decl, &indent))?;
|
||||||
document(w, cx, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
@@ -1991,17 +1991,27 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
t: &clean::Trait) -> fmt::Result {
|
t: &clean::Trait) -> fmt::Result {
|
||||||
let mut bounds = String::new();
|
let mut bounds = String::new();
|
||||||
|
let mut bounds_plain = String::new();
|
||||||
if !t.bounds.is_empty() {
|
if !t.bounds.is_empty() {
|
||||||
if !bounds.is_empty() {
|
if !bounds.is_empty() {
|
||||||
bounds.push(' ');
|
bounds.push(' ');
|
||||||
|
bounds_plain.push(' ');
|
||||||
}
|
}
|
||||||
bounds.push_str(": ");
|
bounds.push_str(": ");
|
||||||
|
bounds_plain.push_str(": ");
|
||||||
for (i, p) in t.bounds.iter().enumerate() {
|
for (i, p) in t.bounds.iter().enumerate() {
|
||||||
if i > 0 { bounds.push_str(" + "); }
|
if i > 0 {
|
||||||
|
bounds.push_str(" + ");
|
||||||
|
bounds_plain.push_str(" + ");
|
||||||
|
}
|
||||||
bounds.push_str(&format!("{}", *p));
|
bounds.push_str(&format!("{}", *p));
|
||||||
|
bounds_plain.push_str(&format!("{:#}", *p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Where clauses in traits are indented nine spaces, per rustdoc.css
|
||||||
|
let indent = " ".to_string();
|
||||||
|
|
||||||
// Output the trait definition
|
// Output the trait definition
|
||||||
write!(w, "<pre class='rust trait'>{}{}trait {}{}{}{} ",
|
write!(w, "<pre class='rust trait'>{}{}trait {}{}{}{} ",
|
||||||
VisSpace(&it.visibility),
|
VisSpace(&it.visibility),
|
||||||
@@ -2009,7 +2019,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
it.name.as_ref().unwrap(),
|
it.name.as_ref().unwrap(),
|
||||||
t.generics,
|
t.generics,
|
||||||
bounds,
|
bounds,
|
||||||
WhereClause(&t.generics))?;
|
WhereClause(&t.generics, indent))?;
|
||||||
|
|
||||||
let types = t.items.iter().filter(|m| m.is_associated_type()).collect::<Vec<_>>();
|
let types = t.items.iter().filter(|m| m.is_associated_type()).collect::<Vec<_>>();
|
||||||
let consts = t.items.iter().filter(|m| m.is_associated_const()).collect::<Vec<_>>();
|
let consts = t.items.iter().filter(|m| m.is_associated_const()).collect::<Vec<_>>();
|
||||||
@@ -2023,7 +2033,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
write!(w, "{{\n")?;
|
write!(w, "{{\n")?;
|
||||||
for t in &types {
|
for t in &types {
|
||||||
write!(w, " ")?;
|
write!(w, " ")?;
|
||||||
render_assoc_item(w, t, AssocItemLink::Anchor(None))?;
|
render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, ";\n")?;
|
write!(w, ";\n")?;
|
||||||
}
|
}
|
||||||
if !types.is_empty() && !consts.is_empty() {
|
if !types.is_empty() && !consts.is_empty() {
|
||||||
@@ -2031,7 +2041,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
}
|
}
|
||||||
for t in &consts {
|
for t in &consts {
|
||||||
write!(w, " ")?;
|
write!(w, " ")?;
|
||||||
render_assoc_item(w, t, AssocItemLink::Anchor(None))?;
|
render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, ";\n")?;
|
write!(w, ";\n")?;
|
||||||
}
|
}
|
||||||
if !consts.is_empty() && !required.is_empty() {
|
if !consts.is_empty() && !required.is_empty() {
|
||||||
@@ -2039,7 +2049,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
}
|
}
|
||||||
for m in &required {
|
for m in &required {
|
||||||
write!(w, " ")?;
|
write!(w, " ")?;
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(None))?;
|
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, ";\n")?;
|
write!(w, ";\n")?;
|
||||||
}
|
}
|
||||||
if !required.is_empty() && !provided.is_empty() {
|
if !required.is_empty() && !provided.is_empty() {
|
||||||
@@ -2047,7 +2057,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
}
|
}
|
||||||
for m in &provided {
|
for m in &provided {
|
||||||
write!(w, " ")?;
|
write!(w, " ")?;
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(None))?;
|
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, " {{ ... }}\n")?;
|
write!(w, " {{ ... }}\n")?;
|
||||||
}
|
}
|
||||||
write!(w, "}}")?;
|
write!(w, "}}")?;
|
||||||
@@ -2068,7 +2078,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
id = id,
|
id = id,
|
||||||
stab = m.stability_class(),
|
stab = m.stability_class(),
|
||||||
ns_id = ns_id)?;
|
ns_id = ns_id)?;
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)))?;
|
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl)?;
|
||||||
write!(w, "</code>")?;
|
write!(w, "</code>")?;
|
||||||
render_stability_since(w, m, t)?;
|
render_stability_since(w, m, t)?;
|
||||||
write!(w, "</span></h3>")?;
|
write!(w, "</span></h3>")?;
|
||||||
@@ -2222,7 +2232,8 @@ fn render_stability_since(w: &mut fmt::Formatter,
|
|||||||
|
|
||||||
fn render_assoc_item(w: &mut fmt::Formatter,
|
fn render_assoc_item(w: &mut fmt::Formatter,
|
||||||
item: &clean::Item,
|
item: &clean::Item,
|
||||||
link: AssocItemLink) -> fmt::Result {
|
link: AssocItemLink,
|
||||||
|
parent: ItemType) -> fmt::Result {
|
||||||
fn method(w: &mut fmt::Formatter,
|
fn method(w: &mut fmt::Formatter,
|
||||||
meth: &clean::Item,
|
meth: &clean::Item,
|
||||||
unsafety: hir::Unsafety,
|
unsafety: hir::Unsafety,
|
||||||
@@ -2230,7 +2241,8 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
|||||||
abi: abi::Abi,
|
abi: abi::Abi,
|
||||||
g: &clean::Generics,
|
g: &clean::Generics,
|
||||||
d: &clean::FnDecl,
|
d: &clean::FnDecl,
|
||||||
link: AssocItemLink)
|
link: AssocItemLink,
|
||||||
|
parent: ItemType)
|
||||||
-> fmt::Result {
|
-> fmt::Result {
|
||||||
let name = meth.name.as_ref().unwrap();
|
let name = meth.name.as_ref().unwrap();
|
||||||
let anchor = format!("#{}.{}", meth.type_(), name);
|
let anchor = format!("#{}.{}", meth.type_(), name);
|
||||||
@@ -2260,7 +2272,17 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
|||||||
AbiSpace(abi),
|
AbiSpace(abi),
|
||||||
name,
|
name,
|
||||||
*g);
|
*g);
|
||||||
let indent = repeat(" ").take(prefix.len()).collect::<String>();
|
let mut indent = repeat(" ").take(prefix.len()).collect::<String>();
|
||||||
|
let where_indent = if parent == ItemType::Trait {
|
||||||
|
indent += " ";
|
||||||
|
" ".to_string()
|
||||||
|
} else if parent == ItemType::Impl {
|
||||||
|
" ".to_string()
|
||||||
|
} else {
|
||||||
|
let prefix = prefix + &format!("{:#}", Method(d, &indent));
|
||||||
|
let prefix = prefix.lines().last().unwrap();
|
||||||
|
repeat(" ").take(prefix.len() + 1).collect::<String>()
|
||||||
|
};
|
||||||
write!(w, "{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
write!(w, "{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
||||||
{generics}{decl}{where_clause}",
|
{generics}{decl}{where_clause}",
|
||||||
ConstnessSpace(vis_constness),
|
ConstnessSpace(vis_constness),
|
||||||
@@ -2270,18 +2292,17 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
|||||||
name = name,
|
name = name,
|
||||||
generics = *g,
|
generics = *g,
|
||||||
decl = Method(d, &indent),
|
decl = Method(d, &indent),
|
||||||
where_clause = WhereClause(g))
|
where_clause = WhereClause(g, where_indent))
|
||||||
}
|
}
|
||||||
match item.inner {
|
match item.inner {
|
||||||
clean::StrippedItem(..) => Ok(()),
|
clean::StrippedItem(..) => Ok(()),
|
||||||
clean::TyMethodItem(ref m) => {
|
clean::TyMethodItem(ref m) => {
|
||||||
method(w, item, m.unsafety, hir::Constness::NotConst,
|
method(w, item, m.unsafety, hir::Constness::NotConst,
|
||||||
m.abi, &m.generics, &m.decl, link)
|
m.abi, &m.generics, &m.decl, link, parent)
|
||||||
}
|
}
|
||||||
clean::MethodItem(ref m) => {
|
clean::MethodItem(ref m) => {
|
||||||
method(w, item, m.unsafety, m.constness,
|
method(w, item, m.unsafety, m.constness,
|
||||||
m.abi, &m.generics, &m.decl,
|
m.abi, &m.generics, &m.decl, link, parent)
|
||||||
link)
|
|
||||||
}
|
}
|
||||||
clean::AssociatedConstItem(ref ty, ref default) => {
|
clean::AssociatedConstItem(ref ty, ref default) => {
|
||||||
assoc_const(w, item, ty, default.as_ref(), link)
|
assoc_const(w, item, ty, default.as_ref(), link)
|
||||||
@@ -2378,11 +2399,15 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||||||
e: &clean::Enum) -> fmt::Result {
|
e: &clean::Enum) -> fmt::Result {
|
||||||
write!(w, "<pre class='rust enum'>")?;
|
write!(w, "<pre class='rust enum'>")?;
|
||||||
render_attributes(w, it)?;
|
render_attributes(w, it)?;
|
||||||
|
let padding = format!("{}enum {}{:#} ",
|
||||||
|
VisSpace(&it.visibility),
|
||||||
|
it.name.as_ref().unwrap(),
|
||||||
|
e.generics);
|
||||||
write!(w, "{}enum {}{}{}",
|
write!(w, "{}enum {}{}{}",
|
||||||
VisSpace(&it.visibility),
|
VisSpace(&it.visibility),
|
||||||
it.name.as_ref().unwrap(),
|
it.name.as_ref().unwrap(),
|
||||||
e.generics,
|
e.generics,
|
||||||
WhereClause(&e.generics))?;
|
WhereClause(&e.generics, padding))?;
|
||||||
if e.variants.is_empty() && !e.variants_stripped {
|
if e.variants.is_empty() && !e.variants_stripped {
|
||||||
write!(w, " {{}}")?;
|
write!(w, " {{}}")?;
|
||||||
} else {
|
} else {
|
||||||
@@ -2517,17 +2542,24 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
|||||||
fields: &[clean::Item],
|
fields: &[clean::Item],
|
||||||
tab: &str,
|
tab: &str,
|
||||||
structhead: bool) -> fmt::Result {
|
structhead: bool) -> fmt::Result {
|
||||||
|
let mut plain = String::new();
|
||||||
write!(w, "{}{}{}",
|
write!(w, "{}{}{}",
|
||||||
VisSpace(&it.visibility),
|
VisSpace(&it.visibility),
|
||||||
if structhead {"struct "} else {""},
|
if structhead {"struct "} else {""},
|
||||||
it.name.as_ref().unwrap())?;
|
it.name.as_ref().unwrap())?;
|
||||||
|
plain.push_str(&format!("{}{}{}",
|
||||||
|
VisSpace(&it.visibility),
|
||||||
|
if structhead {"struct "} else {""},
|
||||||
|
it.name.as_ref().unwrap()));
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
|
plain.push_str(&format!("{:#}", g));
|
||||||
write!(w, "{}", g)?
|
write!(w, "{}", g)?
|
||||||
}
|
}
|
||||||
match ty {
|
match ty {
|
||||||
doctree::Plain => {
|
doctree::Plain => {
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
write!(w, "{}", WhereClause(g))?
|
let pad = repeat(" ").take(plain.len() + 1).collect::<String>();
|
||||||
|
write!(w, "{}", WhereClause(g, pad))?
|
||||||
}
|
}
|
||||||
let mut has_visible_fields = false;
|
let mut has_visible_fields = false;
|
||||||
write!(w, " {{")?;
|
write!(w, " {{")?;
|
||||||
@@ -2556,30 +2588,37 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
|||||||
}
|
}
|
||||||
doctree::Tuple => {
|
doctree::Tuple => {
|
||||||
write!(w, "(")?;
|
write!(w, "(")?;
|
||||||
|
plain.push_str("(");
|
||||||
for (i, field) in fields.iter().enumerate() {
|
for (i, field) in fields.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
write!(w, ", ")?;
|
write!(w, ", ")?;
|
||||||
|
plain.push_str(", ");
|
||||||
}
|
}
|
||||||
match field.inner {
|
match field.inner {
|
||||||
clean::StrippedItem(box clean::StructFieldItem(..)) => {
|
clean::StrippedItem(box clean::StructFieldItem(..)) => {
|
||||||
|
plain.push_str("_");
|
||||||
write!(w, "_")?
|
write!(w, "_")?
|
||||||
}
|
}
|
||||||
clean::StructFieldItem(ref ty) => {
|
clean::StructFieldItem(ref ty) => {
|
||||||
|
plain.push_str(&format!("{}{:#}", VisSpace(&field.visibility), *ty));
|
||||||
write!(w, "{}{}", VisSpace(&field.visibility), *ty)?
|
write!(w, "{}{}", VisSpace(&field.visibility), *ty)?
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(w, ")")?;
|
write!(w, ")")?;
|
||||||
|
plain.push_str(")");
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
write!(w, "{}", WhereClause(g))?
|
let pad = repeat(" ").take(plain.len() + 1).collect::<String>();
|
||||||
|
write!(w, "{}", WhereClause(g, pad))?
|
||||||
}
|
}
|
||||||
write!(w, ";")?;
|
write!(w, ";")?;
|
||||||
}
|
}
|
||||||
doctree::Unit => {
|
doctree::Unit => {
|
||||||
// Needed for PhantomData.
|
// Needed for PhantomData.
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
write!(w, "{}", WhereClause(g))?
|
let pad = repeat(" ").take(plain.len() + 1).collect::<String>();
|
||||||
|
write!(w, "{}", WhereClause(g, pad))?
|
||||||
}
|
}
|
||||||
write!(w, ";")?;
|
write!(w, ";")?;
|
||||||
}
|
}
|
||||||
@@ -2592,13 +2631,20 @@ fn render_union(w: &mut fmt::Formatter, it: &clean::Item,
|
|||||||
fields: &[clean::Item],
|
fields: &[clean::Item],
|
||||||
tab: &str,
|
tab: &str,
|
||||||
structhead: bool) -> fmt::Result {
|
structhead: bool) -> fmt::Result {
|
||||||
|
let mut plain = String::new();
|
||||||
write!(w, "{}{}{}",
|
write!(w, "{}{}{}",
|
||||||
VisSpace(&it.visibility),
|
VisSpace(&it.visibility),
|
||||||
if structhead {"union "} else {""},
|
if structhead {"union "} else {""},
|
||||||
it.name.as_ref().unwrap())?;
|
it.name.as_ref().unwrap())?;
|
||||||
|
plain.push_str(&format!("{}{}{}",
|
||||||
|
VisSpace(&it.visibility),
|
||||||
|
if structhead {"union "} else {""},
|
||||||
|
it.name.as_ref().unwrap()));
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
write!(w, "{}", g)?;
|
write!(w, "{}", g)?;
|
||||||
write!(w, "{}", WhereClause(g))?;
|
plain.push_str(&format!("{:#}", g));
|
||||||
|
let pad = repeat(" ").take(plain.len() + 1).collect::<String>();
|
||||||
|
write!(w, "{}", WhereClause(g, pad))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(w, " {{\n{}", tab)?;
|
write!(w, " {{\n{}", tab)?;
|
||||||
@@ -2789,7 +2835,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
|||||||
write!(w, "<h4 id='{}' class='{}'>", id, item_type)?;
|
write!(w, "<h4 id='{}' class='{}'>", id, item_type)?;
|
||||||
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
|
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
|
||||||
write!(w, "<code>")?;
|
write!(w, "<code>")?;
|
||||||
render_assoc_item(w, item, link.anchor(&id))?;
|
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?;
|
||||||
write!(w, "</code>")?;
|
write!(w, "</code>")?;
|
||||||
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
render_stability_since_raw(w, item.stable_since(), outer_version)?;
|
||||||
write!(w, "</span></h4>\n")?;
|
write!(w, "</span></h4>\n")?;
|
||||||
@@ -2899,10 +2945,12 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
|||||||
|
|
||||||
fn item_typedef(w: &mut fmt::Formatter, cx: &Context, 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 {
|
||||||
|
let indent = format!("type {}{:#} ", it.name.as_ref().unwrap(), t.generics);
|
||||||
|
let indent = repeat(" ").take(indent.len()).collect::<String>();
|
||||||
write!(w, "<pre class='rust typedef'>type {}{}{where_clause} = {type_};</pre>",
|
write!(w, "<pre class='rust typedef'>type {}{}{where_clause} = {type_};</pre>",
|
||||||
it.name.as_ref().unwrap(),
|
it.name.as_ref().unwrap(),
|
||||||
t.generics,
|
t.generics,
|
||||||
where_clause = WhereClause(&t.generics),
|
where_clause = WhereClause(&t.generics, indent),
|
||||||
type_ = t.type_)?;
|
type_ = t.type_)?;
|
||||||
|
|
||||||
document(w, cx, it)
|
document(w, cx, it)
|
||||||
|
|||||||
Reference in New Issue
Block a user