Rollup merge of #36679 - QuietMisdreavus:rustdoc-line-breaks, r=steveklabnik
rustdoc: print non-self arguments of bare functions and struct methods on their own line This change alters the formatting rustdoc uses when it creates function and struct method documentation. For bare functions, each argument is printed on its own line. For struct methods, non-self arguments are printed on their own line. In both cases, no line breaks are introduced if there are no arguments, and for struct methods, no line breaks are introduced if there is only a single self argument. This should aid readability of long function signatures and allow for greater comprehension of these functions. I've run rustdoc with these changes on my crate egg-mode and its set of dependencies and put the result [on my server](https://shiva.icesoldier.me/doc-custom/egg_mode/). Of note, here are a few shortcut links that highlight the changes: * [Bare function with a long signature](https://shiva.icesoldier.me/doc-custom/egg_mode/place/fn.reverse_geocode.html) * [Struct methods, with single self argument and with self and non-self arguments](https://shiva.icesoldier.me/doc-custom/egg_mode/tweet/struct.Timeline.html#method.reset) * [Bare functions with no arguments](https://shiva.icesoldier.me/doc-custom/rand/fn.thread_rng.html) and [struct methods with no arguments](https://shiva.icesoldier.me/doc-custom/hyper/client/struct.Client.html#method.new) are left unchanged. This PR consists of two commits: one for bare functions and one for struct methods.
This commit is contained in:
commit
6717dba276
3 changed files with 356 additions and 102 deletions
|
@ -42,7 +42,7 @@ pub struct UnsafetySpace(pub hir::Unsafety);
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct ConstnessSpace(pub hir::Constness);
|
pub struct ConstnessSpace(pub hir::Constness);
|
||||||
/// Wrapper struct for properly emitting a method declaration.
|
/// Wrapper struct for properly emitting a method declaration.
|
||||||
pub struct Method<'a>(pub &'a clean::FnDecl);
|
pub struct Method<'a>(pub &'a clean::FnDecl, pub &'a str);
|
||||||
/// Similar to VisSpace, but used for mutability
|
/// Similar to VisSpace, but used for mutability
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct MutableSpace(pub clean::Mutability);
|
pub struct MutableSpace(pub clean::Mutability);
|
||||||
|
@ -84,7 +84,7 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
for (i, item) in self.0.iter().enumerate() {
|
for (i, item) in self.0.iter().enumerate() {
|
||||||
if i != 0 { write!(f, ", ")?; }
|
if i != 0 { write!(f, ", ")?; }
|
||||||
write!(f, "{}", item)?;
|
fmt::Display::fmt(item, f)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(" + ")?;
|
f.write_str(" + ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", *bound)?;
|
fmt::Display::fmt(bound, f)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -106,35 +106,51 @@ impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||||
impl fmt::Display for clean::Generics {
|
impl fmt::Display for clean::Generics {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if self.lifetimes.is_empty() && self.type_params.is_empty() { return Ok(()) }
|
if self.lifetimes.is_empty() && self.type_params.is_empty() { return Ok(()) }
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str("<")?;
|
||||||
|
} else {
|
||||||
f.write_str("<")?;
|
f.write_str("<")?;
|
||||||
|
}
|
||||||
|
|
||||||
for (i, life) in self.lifetimes.iter().enumerate() {
|
for (i, life) in self.lifetimes.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", *life)?;
|
write!(f, "{}", *life)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.type_params.is_empty() {
|
if !self.type_params.is_empty() {
|
||||||
if !self.lifetimes.is_empty() {
|
if !self.lifetimes.is_empty() {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
for (i, tp) in self.type_params.iter().enumerate() {
|
for (i, tp) in self.type_params.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(", ")?
|
f.write_str(", ")?
|
||||||
}
|
}
|
||||||
f.write_str(&tp.name)?;
|
f.write_str(&tp.name)?;
|
||||||
|
|
||||||
if !tp.bounds.is_empty() {
|
if !tp.bounds.is_empty() {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, ": {:#}", TyParamBounds(&tp.bounds))?;
|
||||||
|
} else {
|
||||||
write!(f, ": {}", TyParamBounds(&tp.bounds))?;
|
write!(f, ": {}", TyParamBounds(&tp.bounds))?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref ty) = tp.default {
|
if let Some(ref ty) = tp.default {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, " = {:#}", ty)?;
|
||||||
|
} else {
|
||||||
write!(f, " = {}", ty)?;
|
write!(f, " = {}", ty)?;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str(">")?;
|
||||||
|
} else {
|
||||||
f.write_str(">")?;
|
f.write_str(">")?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +161,11 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
||||||
if gens.where_predicates.is_empty() {
|
if gens.where_predicates.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str(" ")?;
|
||||||
|
} else {
|
||||||
f.write_str(" <span class='where'>where ")?;
|
f.write_str(" <span class='where'>where ")?;
|
||||||
|
}
|
||||||
for (i, pred) in gens.where_predicates.iter().enumerate() {
|
for (i, pred) in gens.where_predicates.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
|
@ -153,8 +173,12 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
||||||
match pred {
|
match pred {
|
||||||
&clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => {
|
&clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => {
|
||||||
let bounds = bounds;
|
let bounds = bounds;
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}: {:#}", ty, TyParamBounds(bounds))?;
|
||||||
|
} else {
|
||||||
write!(f, "{}: {}", ty, TyParamBounds(bounds))?;
|
write!(f, "{}: {}", ty, TyParamBounds(bounds))?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
&clean::WherePredicate::RegionPredicate { ref lifetime,
|
&clean::WherePredicate::RegionPredicate { ref lifetime,
|
||||||
ref bounds } => {
|
ref bounds } => {
|
||||||
write!(f, "{}: ", lifetime)?;
|
write!(f, "{}: ", lifetime)?;
|
||||||
|
@ -167,11 +191,17 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => {
|
&clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#} == {:#}", lhs, rhs)?;
|
||||||
|
} else {
|
||||||
write!(f, "{} == {}", lhs, rhs)?;
|
write!(f, "{} == {}", lhs, rhs)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if !f.alternate() {
|
||||||
f.write_str("</span>")?;
|
f.write_str("</span>")?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,17 +216,29 @@ impl fmt::Display for clean::Lifetime {
|
||||||
impl fmt::Display for clean::PolyTrait {
|
impl fmt::Display for clean::PolyTrait {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if !self.lifetimes.is_empty() {
|
if !self.lifetimes.is_empty() {
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str("for<")?;
|
||||||
|
} else {
|
||||||
f.write_str("for<")?;
|
f.write_str("for<")?;
|
||||||
|
}
|
||||||
for (i, lt) in self.lifetimes.iter().enumerate() {
|
for (i, lt) in self.lifetimes.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", lt)?;
|
write!(f, "{}", lt)?;
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str("> ")?;
|
||||||
|
} else {
|
||||||
f.write_str("> ")?;
|
f.write_str("> ")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", self.trait_)
|
||||||
|
} else {
|
||||||
write!(f, "{}", self.trait_)
|
write!(f, "{}", self.trait_)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for clean::TyParamBound {
|
impl fmt::Display for clean::TyParamBound {
|
||||||
|
@ -210,10 +252,14 @@ impl fmt::Display for clean::TyParamBound {
|
||||||
hir::TraitBoundModifier::None => "",
|
hir::TraitBoundModifier::None => "",
|
||||||
hir::TraitBoundModifier::Maybe => "?",
|
hir::TraitBoundModifier::Maybe => "?",
|
||||||
};
|
};
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{}{:#}", modifier_str, *ty)
|
||||||
|
} else {
|
||||||
write!(f, "{}{}", modifier_str, *ty)
|
write!(f, "{}{}", modifier_str, *ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for clean::PathParameters {
|
impl fmt::Display for clean::PathParameters {
|
||||||
|
@ -223,32 +269,48 @@ impl fmt::Display for clean::PathParameters {
|
||||||
ref lifetimes, ref types, ref bindings
|
ref lifetimes, ref types, ref bindings
|
||||||
} => {
|
} => {
|
||||||
if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() {
|
if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() {
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str("<")?;
|
||||||
|
} else {
|
||||||
f.write_str("<")?;
|
f.write_str("<")?;
|
||||||
|
}
|
||||||
let mut comma = false;
|
let mut comma = false;
|
||||||
for lifetime in lifetimes {
|
for lifetime in lifetimes {
|
||||||
if comma {
|
if comma {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
comma = true;
|
comma = true;
|
||||||
write!(f, "{}", *lifetime)?;
|
write!(f, "{}", *lifetime)?;
|
||||||
}
|
}
|
||||||
for ty in types {
|
for ty in types {
|
||||||
if comma {
|
if comma {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
comma = true;
|
comma = true;
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", *ty)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", *ty)?;
|
write!(f, "{}", *ty)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for binding in bindings {
|
for binding in bindings {
|
||||||
if comma {
|
if comma {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
comma = true;
|
comma = true;
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", *binding)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", *binding)?;
|
write!(f, "{}", *binding)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str(">")?;
|
||||||
|
} else {
|
||||||
f.write_str(">")?;
|
f.write_str(">")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clean::PathParameters::Parenthesized { ref inputs, ref output } => {
|
clean::PathParameters::Parenthesized { ref inputs, ref output } => {
|
||||||
f.write_str("(")?;
|
f.write_str("(")?;
|
||||||
let mut comma = false;
|
let mut comma = false;
|
||||||
|
@ -257,12 +319,19 @@ impl fmt::Display for clean::PathParameters {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
}
|
}
|
||||||
comma = true;
|
comma = true;
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", *ty)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", *ty)?;
|
write!(f, "{}", *ty)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
f.write_str(")")?;
|
f.write_str(")")?;
|
||||||
if let Some(ref ty) = *output {
|
if let Some(ref ty) = *output {
|
||||||
f.write_str(" -> ")?;
|
if f.alternate() {
|
||||||
write!(f, "{}", ty)?;
|
write!(f, " -> {:#}", ty)?;
|
||||||
|
} else {
|
||||||
|
write!(f, " -> {}", ty)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,8 +342,12 @@ impl fmt::Display for clean::PathParameters {
|
||||||
impl fmt::Display for clean::PathSegment {
|
impl fmt::Display for clean::PathSegment {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
f.write_str(&self.name)?;
|
f.write_str(&self.name)?;
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", self.params)
|
||||||
|
} else {
|
||||||
write!(f, "{}", self.params)
|
write!(f, "{}", self.params)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for clean::Path {
|
impl fmt::Display for clean::Path {
|
||||||
|
@ -287,8 +360,12 @@ impl fmt::Display for clean::Path {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str("::")?
|
f.write_str("::")?
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", seg)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", seg)?;
|
write!(f, "{}", seg)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +426,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||||
match rel_root {
|
match rel_root {
|
||||||
Some(mut root) => {
|
Some(mut root) => {
|
||||||
for seg in &path.segments[..amt] {
|
for seg in &path.segments[..amt] {
|
||||||
if "super" == seg.name || "self" == seg.name {
|
if "super" == seg.name || "self" == seg.name || w.alternate() {
|
||||||
write!(w, "{}::", seg.name)?;
|
write!(w, "{}::", seg.name)?;
|
||||||
} else {
|
} else {
|
||||||
root.push_str(&seg.name);
|
root.push_str(&seg.name);
|
||||||
|
@ -368,7 +445,11 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if w.alternate() {
|
||||||
|
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
|
||||||
|
} else {
|
||||||
write!(w, "{}{}", HRef::new(did, &last.name), last.params)?;
|
write!(w, "{}{}", HRef::new(did, &last.name), last.params)?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,6 +458,7 @@ fn primitive_link(f: &mut fmt::Formatter,
|
||||||
name: &str) -> fmt::Result {
|
name: &str) -> fmt::Result {
|
||||||
let m = cache();
|
let m = cache();
|
||||||
let mut needs_termination = false;
|
let mut needs_termination = false;
|
||||||
|
if !f.alternate() {
|
||||||
match m.primitive_locations.get(&prim) {
|
match m.primitive_locations.get(&prim) {
|
||||||
Some(&LOCAL_CRATE) => {
|
Some(&LOCAL_CRATE) => {
|
||||||
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
|
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
|
||||||
|
@ -405,6 +487,7 @@ fn primitive_link(f: &mut fmt::Formatter,
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
write!(f, "{}", name)?;
|
write!(f, "{}", name)?;
|
||||||
if needs_termination {
|
if needs_termination {
|
||||||
write!(f, "</a>")?;
|
write!(f, "</a>")?;
|
||||||
|
@ -419,7 +502,7 @@ fn tybounds(w: &mut fmt::Formatter,
|
||||||
Some(ref params) => {
|
Some(ref params) => {
|
||||||
for param in params {
|
for param in params {
|
||||||
write!(w, " + ")?;
|
write!(w, " + ")?;
|
||||||
write!(w, "{}", *param)?;
|
fmt::Display::fmt(param, w)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -436,10 +519,12 @@ impl<'a> HRef<'a> {
|
||||||
impl<'a> fmt::Display for HRef<'a> {
|
impl<'a> fmt::Display for HRef<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match href(self.did) {
|
match href(self.did) {
|
||||||
Some((url, shortty, fqp)) => {
|
Some((url, shortty, fqp)) => if !f.alternate() {
|
||||||
write!(f, "<a class='{}' href='{}' title='{}'>{}</a>",
|
write!(f, "<a class='{}' href='{}' title='{}'>{}</a>",
|
||||||
shortty, url, fqp.join("::"), self.text)
|
shortty, url, fqp.join("::"), self.text)
|
||||||
}
|
} else {
|
||||||
|
write!(f, "{}", self.text)
|
||||||
|
},
|
||||||
_ => write!(f, "{}", self.text),
|
_ => write!(f, "{}", self.text),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -459,49 +544,68 @@ impl fmt::Display for clean::Type {
|
||||||
clean::Infer => write!(f, "_"),
|
clean::Infer => write!(f, "_"),
|
||||||
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()),
|
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()),
|
||||||
clean::BareFunction(ref decl) => {
|
clean::BareFunction(ref decl) => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{}{}fn{:#}{:#}",
|
||||||
|
UnsafetySpace(decl.unsafety),
|
||||||
|
AbiSpace(decl.abi),
|
||||||
|
decl.generics,
|
||||||
|
decl.decl)
|
||||||
|
} else {
|
||||||
write!(f, "{}{}fn{}{}",
|
write!(f, "{}{}fn{}{}",
|
||||||
UnsafetySpace(decl.unsafety),
|
UnsafetySpace(decl.unsafety),
|
||||||
AbiSpace(decl.abi),
|
AbiSpace(decl.abi),
|
||||||
decl.generics,
|
decl.generics,
|
||||||
decl.decl)
|
decl.decl)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clean::Tuple(ref typs) => {
|
clean::Tuple(ref typs) => {
|
||||||
match &typs[..] {
|
match &typs[..] {
|
||||||
&[] => primitive_link(f, PrimitiveType::Tuple, "()"),
|
&[] => primitive_link(f, PrimitiveType::Tuple, "()"),
|
||||||
&[ref one] => {
|
&[ref one] => {
|
||||||
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
||||||
write!(f, "{},", one)?;
|
//carry f.alternate() into this display w/o branching manually
|
||||||
primitive_link(f, PrimitiveType::Tuple, ")")
|
fmt::Display::fmt(one, f)?;
|
||||||
|
primitive_link(f, PrimitiveType::Tuple, ",)")
|
||||||
}
|
}
|
||||||
many => {
|
many => {
|
||||||
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
||||||
write!(f, "{}", CommaSep(&many))?;
|
fmt::Display::fmt(&CommaSep(&many), f)?;
|
||||||
primitive_link(f, PrimitiveType::Tuple, ")")
|
primitive_link(f, PrimitiveType::Tuple, ")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::Vector(ref t) => {
|
clean::Vector(ref t) => {
|
||||||
primitive_link(f, PrimitiveType::Slice, &format!("["))?;
|
primitive_link(f, PrimitiveType::Slice, &format!("["))?;
|
||||||
write!(f, "{}", t)?;
|
fmt::Display::fmt(t, f)?;
|
||||||
primitive_link(f, PrimitiveType::Slice, &format!("]"))
|
primitive_link(f, PrimitiveType::Slice, &format!("]"))
|
||||||
}
|
}
|
||||||
clean::FixedVector(ref t, ref s) => {
|
clean::FixedVector(ref t, ref s) => {
|
||||||
primitive_link(f, PrimitiveType::Array, "[")?;
|
primitive_link(f, PrimitiveType::Array, "[")?;
|
||||||
write!(f, "{}", t)?;
|
fmt::Display::fmt(t, f)?;
|
||||||
|
if f.alternate() {
|
||||||
|
primitive_link(f, PrimitiveType::Array,
|
||||||
|
&format!("; {}]", s))
|
||||||
|
} else {
|
||||||
primitive_link(f, PrimitiveType::Array,
|
primitive_link(f, PrimitiveType::Array,
|
||||||
&format!("; {}]", Escape(s)))
|
&format!("; {}]", Escape(s)))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clean::Never => f.write_str("!"),
|
clean::Never => f.write_str("!"),
|
||||||
clean::RawPointer(m, ref t) => {
|
clean::RawPointer(m, ref t) => {
|
||||||
match **t {
|
match **t {
|
||||||
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
|
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
|
||||||
|
if f.alternate() {
|
||||||
|
primitive_link(f, clean::PrimitiveType::RawPointer,
|
||||||
|
&format!("*{}{:#}", RawMutableSpace(m), t))
|
||||||
|
} else {
|
||||||
primitive_link(f, clean::PrimitiveType::RawPointer,
|
primitive_link(f, clean::PrimitiveType::RawPointer,
|
||||||
&format!("*{}{}", RawMutableSpace(m), t))
|
&format!("*{}{}", RawMutableSpace(m), t))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
primitive_link(f, clean::PrimitiveType::RawPointer,
|
primitive_link(f, clean::PrimitiveType::RawPointer,
|
||||||
&format!("*{}", RawMutableSpace(m)))?;
|
&format!("*{}", RawMutableSpace(m)))?;
|
||||||
write!(f, "{}", t)
|
fmt::Display::fmt(t, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,28 +619,47 @@ impl fmt::Display for clean::Type {
|
||||||
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
|
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
|
||||||
match **bt {
|
match **bt {
|
||||||
clean::Generic(_) =>
|
clean::Generic(_) =>
|
||||||
|
if f.alternate() {
|
||||||
primitive_link(f, PrimitiveType::Slice,
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
&format!("&{}{}[{}]", lt, m, **bt)),
|
&format!("&{}{}[{:#}]", lt, m, **bt))
|
||||||
|
} else {
|
||||||
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
|
&format!("&{}{}[{}]", lt, m, **bt))
|
||||||
|
},
|
||||||
_ => {
|
_ => {
|
||||||
|
if f.alternate() {
|
||||||
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
|
&format!("&{}{}[", lt, m))?;
|
||||||
|
write!(f, "{:#}", **bt)?;
|
||||||
|
} else {
|
||||||
primitive_link(f, PrimitiveType::Slice,
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
&format!("&{}{}[", lt, m))?;
|
&format!("&{}{}[", lt, m))?;
|
||||||
write!(f, "{}", **bt)?;
|
write!(f, "{}", **bt)?;
|
||||||
|
}
|
||||||
primitive_link(f, PrimitiveType::Slice, "]")
|
primitive_link(f, PrimitiveType::Slice, "]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "&{}{}{:#}", lt, m, **ty)
|
||||||
|
} else {
|
||||||
write!(f, "&{}{}{}", lt, m, **ty)
|
write!(f, "&{}{}{}", lt, m, **ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clean::PolyTraitRef(ref bounds) => {
|
clean::PolyTraitRef(ref bounds) => {
|
||||||
for (i, bound) in bounds.iter().enumerate() {
|
for (i, bound) in bounds.iter().enumerate() {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
write!(f, " + ")?;
|
write!(f, " + ")?;
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", *bound)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", *bound)?;
|
write!(f, "{}", *bound)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
clean::ImplTrait(ref bounds) => {
|
clean::ImplTrait(ref bounds) => {
|
||||||
|
@ -545,8 +668,12 @@ impl fmt::Display for clean::Type {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
write!(f, " + ")?;
|
write!(f, " + ")?;
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", *bound)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", *bound)?;
|
write!(f, "{}", *bound)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
// It's pretty unsightly to look at `<A as B>::C` in output, and
|
// It's pretty unsightly to look at `<A as B>::C` in output, and
|
||||||
|
@ -564,7 +691,11 @@ impl fmt::Display for clean::Type {
|
||||||
ref self_type,
|
ref self_type,
|
||||||
trait_: box clean::ResolvedPath { did, ref typarams, .. },
|
trait_: box clean::ResolvedPath { did, ref typarams, .. },
|
||||||
} => {
|
} => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}::", self_type)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}::", self_type)?;
|
write!(f, "{}::", self_type)?;
|
||||||
|
}
|
||||||
let path = clean::Path::singleton(name.clone());
|
let path = clean::Path::singleton(name.clone());
|
||||||
resolved_path(f, did, &path, false)?;
|
resolved_path(f, did, &path, false)?;
|
||||||
|
|
||||||
|
@ -573,8 +704,12 @@ impl fmt::Display for clean::Type {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
clean::QPath { ref name, ref self_type, ref trait_ } => {
|
clean::QPath { ref name, ref self_type, ref trait_ } => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "<{:#} as {:#}>::{}", self_type, trait_, name)
|
||||||
|
} else {
|
||||||
write!(f, "<{} as {}>::{}", self_type, trait_, name)
|
write!(f, "<{} as {}>::{}", self_type, trait_, name)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clean::Unique(..) => {
|
clean::Unique(..) => {
|
||||||
panic!("should have been cleaned")
|
panic!("should have been cleaned")
|
||||||
}
|
}
|
||||||
|
@ -583,24 +718,30 @@ 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 {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "impl{:#} ", i.generics)?;
|
||||||
|
} else {
|
||||||
write!(f, "impl{} ", i.generics)?;
|
write!(f, "impl{} ", i.generics)?;
|
||||||
|
}
|
||||||
if let Some(ref ty) = i.trait_ {
|
if let Some(ref ty) = i.trait_ {
|
||||||
write!(f, "{}",
|
write!(f, "{}",
|
||||||
if i.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" })?;
|
if i.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" })?;
|
||||||
if link_trait {
|
if link_trait {
|
||||||
write!(f, "{}", *ty)?;
|
fmt::Display::fmt(ty, f)?;
|
||||||
} 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();
|
||||||
write!(f, "{}{}", last.name, last.params)?;
|
fmt::Display::fmt(&last.name, f)?;
|
||||||
|
fmt::Display::fmt(&last.params, f)?;
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, " for ")?;
|
write!(f, " for ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}{}", i.for_, WhereClause(&i.generics))?;
|
fmt::Display::fmt(&i.for_, f)?;
|
||||||
|
fmt::Display::fmt(&WhereClause(&i.generics), f)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,12 +759,16 @@ pub fn fmt_impl_for_trait_page(i: &clean::Impl, f: &mut fmt::Formatter) -> fmt::
|
||||||
impl fmt::Display for clean::Arguments {
|
impl fmt::Display for clean::Arguments {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
for (i, input) in self.values.iter().enumerate() {
|
for (i, input) in self.values.iter().enumerate() {
|
||||||
if i > 0 { write!(f, ", ")?; }
|
|
||||||
if !input.name.is_empty() {
|
if !input.name.is_empty() {
|
||||||
write!(f, "{}: ", input.name)?;
|
write!(f, "{}: ", input.name)?;
|
||||||
}
|
}
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#}", input.type_)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", input.type_)?;
|
write!(f, "{}", input.type_)?;
|
||||||
}
|
}
|
||||||
|
if i + 1 < self.values.len() { write!(f, ", ")?; }
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,6 +777,7 @@ impl fmt::Display for clean::FunctionRetTy {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
|
clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
|
||||||
|
clean::Return(ref ty) if f.alternate() => write!(f, " -> {:#}", ty),
|
||||||
clean::Return(ref ty) => write!(f, " -> {}", ty),
|
clean::Return(ref ty) => write!(f, " -> {}", ty),
|
||||||
clean::DefaultReturn => Ok(()),
|
clean::DefaultReturn => Ok(()),
|
||||||
}
|
}
|
||||||
|
@ -641,40 +787,107 @@ impl fmt::Display for clean::FunctionRetTy {
|
||||||
impl fmt::Display for clean::FnDecl {
|
impl fmt::Display for clean::FnDecl {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if self.variadic {
|
if self.variadic {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "({args:#}, ...){arrow:#}", args = self.inputs, arrow = self.output)
|
||||||
|
} else {
|
||||||
write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
|
write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "({args:#}){arrow:#}", args = self.inputs, arrow = self.output)
|
||||||
} else {
|
} else {
|
||||||
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
|
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for Method<'a> {
|
impl<'a> fmt::Display for Method<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let decl = self.0;
|
let decl = self.0;
|
||||||
|
let indent = self.1;
|
||||||
|
let amp = if f.alternate() { "&" } else { "&" };
|
||||||
let mut args = String::new();
|
let mut args = String::new();
|
||||||
|
let mut args_plain = String::new();
|
||||||
for (i, input) in decl.inputs.values.iter().enumerate() {
|
for (i, input) in decl.inputs.values.iter().enumerate() {
|
||||||
if i > 0 || !args.is_empty() { args.push_str(", "); }
|
|
||||||
if let Some(selfty) = input.to_self() {
|
if let Some(selfty) = input.to_self() {
|
||||||
match selfty {
|
match selfty {
|
||||||
clean::SelfValue => args.push_str("self"),
|
clean::SelfValue => {
|
||||||
|
args.push_str("self");
|
||||||
|
args_plain.push_str("self");
|
||||||
|
}
|
||||||
clean::SelfBorrowed(Some(ref lt), mtbl) => {
|
clean::SelfBorrowed(Some(ref lt), mtbl) => {
|
||||||
args.push_str(&format!("&{} {}self", *lt, MutableSpace(mtbl)));
|
args.push_str(&format!("{}{} {}self", amp, *lt, MutableSpace(mtbl)));
|
||||||
|
args_plain.push_str(&format!("&{} {}self", *lt, MutableSpace(mtbl)));
|
||||||
}
|
}
|
||||||
clean::SelfBorrowed(None, mtbl) => {
|
clean::SelfBorrowed(None, mtbl) => {
|
||||||
args.push_str(&format!("&{}self", MutableSpace(mtbl)));
|
args.push_str(&format!("{}{}self", amp, MutableSpace(mtbl)));
|
||||||
|
args_plain.push_str(&format!("&{}self", MutableSpace(mtbl)));
|
||||||
}
|
}
|
||||||
clean::SelfExplicit(ref typ) => {
|
clean::SelfExplicit(ref typ) => {
|
||||||
|
if f.alternate() {
|
||||||
|
args.push_str(&format!("self: {:#}", *typ));
|
||||||
|
} else {
|
||||||
args.push_str(&format!("self: {}", *typ));
|
args.push_str(&format!("self: {}", *typ));
|
||||||
}
|
}
|
||||||
|
args_plain.push_str(&format!("self: {:#}", *typ));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if i > 0 {
|
||||||
|
args.push_str("<br> ");
|
||||||
|
args_plain.push_str(" ");
|
||||||
|
}
|
||||||
if !input.name.is_empty() {
|
if !input.name.is_empty() {
|
||||||
args.push_str(&format!("{}: ", input.name));
|
args.push_str(&format!("{}: ", input.name));
|
||||||
|
args_plain.push_str(&format!("{}: ", input.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f.alternate() {
|
||||||
|
args.push_str(&format!("{:#}", input.type_));
|
||||||
|
} else {
|
||||||
args.push_str(&format!("{}", input.type_));
|
args.push_str(&format!("{}", input.type_));
|
||||||
}
|
}
|
||||||
|
args_plain.push_str(&format!("{:#}", input.type_));
|
||||||
}
|
}
|
||||||
write!(f, "({args}){arrow}", args = args, arrow = decl.output)
|
if i + 1 < decl.inputs.values.len() {
|
||||||
|
args.push_str(",");
|
||||||
|
args_plain.push_str(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if decl.variadic {
|
||||||
|
args.push_str(",<br> ...");
|
||||||
|
args_plain.push_str(", ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
let arrow_plain = format!("{:#}", decl.output);
|
||||||
|
let arrow = if f.alternate() {
|
||||||
|
format!("{:#}", decl.output)
|
||||||
|
} else {
|
||||||
|
format!("{}", decl.output)
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut output: String;
|
||||||
|
let plain: String;
|
||||||
|
if arrow.is_empty() {
|
||||||
|
output = format!("({})", args);
|
||||||
|
plain = format!("{}({})", indent.replace(" ", " "), args_plain);
|
||||||
|
} else {
|
||||||
|
output = format!("({args})<br>{arrow}", args = args, arrow = arrow);
|
||||||
|
plain = format!("{indent}({args}){arrow}",
|
||||||
|
indent = indent.replace(" ", " "),
|
||||||
|
args = args_plain,
|
||||||
|
arrow = arrow_plain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if plain.len() > 80 {
|
||||||
|
let pad = format!("<br>{}", indent);
|
||||||
|
output = output.replace("<br>", &pad);
|
||||||
|
} else {
|
||||||
|
output = output.replace("<br>", "");
|
||||||
|
}
|
||||||
|
write!(f, "{}", output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,8 +981,12 @@ impl fmt::Display for clean::ViewListIdent {
|
||||||
|
|
||||||
impl fmt::Display for clean::TypeBinding {
|
impl fmt::Display for clean::TypeBinding {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{}={:#}", self.name, self.ty)
|
||||||
|
} else {
|
||||||
write!(f, "{}={}", self.name, self.ty)
|
write!(f, "{}={}", self.name, self.ty)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for MutableSpace {
|
impl fmt::Display for MutableSpace {
|
||||||
|
@ -792,10 +1009,11 @@ impl fmt::Display for RawMutableSpace {
|
||||||
|
|
||||||
impl fmt::Display for AbiSpace {
|
impl fmt::Display for AbiSpace {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let quot = if f.alternate() { "\"" } else { """ };
|
||||||
match self.0 {
|
match self.0 {
|
||||||
Abi::Rust => Ok(()),
|
Abi::Rust => Ok(()),
|
||||||
Abi::C => write!(f, "extern "),
|
Abi::C => write!(f, "extern "),
|
||||||
abi => write!(f, "extern "{}" ", abi.name()),
|
abi => write!(f, "extern {0}{1}{0} ", quot, abi.name()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1967,6 +1967,14 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
UnstableFeatures::Allow => f.constness,
|
UnstableFeatures::Allow => f.constness,
|
||||||
_ => hir::Constness::NotConst
|
_ => hir::Constness::NotConst
|
||||||
};
|
};
|
||||||
|
let prefix = format!("{}{}{}{:#}fn {}{:#}",
|
||||||
|
VisSpace(&it.visibility),
|
||||||
|
ConstnessSpace(vis_constness),
|
||||||
|
UnsafetySpace(f.unsafety),
|
||||||
|
AbiSpace(f.abi),
|
||||||
|
it.name.as_ref().unwrap(),
|
||||||
|
f.generics);
|
||||||
|
let indent = repeat(" ").take(prefix.len()).collect::<String>();
|
||||||
write!(w, "<pre class='rust fn'>{vis}{constness}{unsafety}{abi}fn \
|
write!(w, "<pre class='rust fn'>{vis}{constness}{unsafety}{abi}fn \
|
||||||
{name}{generics}{decl}{where_clause}</pre>",
|
{name}{generics}{decl}{where_clause}</pre>",
|
||||||
vis = VisSpace(&it.visibility),
|
vis = VisSpace(&it.visibility),
|
||||||
|
@ -1976,7 +1984,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
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),
|
||||||
decl = f.decl)?;
|
decl = Method(&f.decl, &indent))?;
|
||||||
document(w, cx, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2246,6 +2254,13 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
||||||
UnstableFeatures::Allow => constness,
|
UnstableFeatures::Allow => constness,
|
||||||
_ => hir::Constness::NotConst
|
_ => hir::Constness::NotConst
|
||||||
};
|
};
|
||||||
|
let prefix = format!("{}{}{:#}fn {}{:#}",
|
||||||
|
ConstnessSpace(vis_constness),
|
||||||
|
UnsafetySpace(unsafety),
|
||||||
|
AbiSpace(abi),
|
||||||
|
name,
|
||||||
|
*g);
|
||||||
|
let indent = repeat(" ").take(prefix.len()).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),
|
||||||
|
@ -2254,7 +2269,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
||||||
href = href,
|
href = href,
|
||||||
name = name,
|
name = name,
|
||||||
generics = *g,
|
generics = *g,
|
||||||
decl = Method(d),
|
decl = Method(d, &indent),
|
||||||
where_clause = WhereClause(g))
|
where_clause = WhereClause(g))
|
||||||
}
|
}
|
||||||
match item.inner {
|
match item.inner {
|
||||||
|
|
21
src/test/rustdoc/line-breaks.rs
Normal file
21
src/test/rustdoc/line-breaks.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
//@count foo/fn.function_with_a_really_long_name.html //pre/br 2
|
||||||
|
pub fn function_with_a_really_long_name(parameter_one: i32,
|
||||||
|
parameter_two: i32)
|
||||||
|
-> Option<i32> {
|
||||||
|
Some(parameter_one + parameter_two)
|
||||||
|
}
|
||||||
|
|
||||||
|
//@count foo/fn.short_name.html //pre/br 0
|
||||||
|
pub fn short_name(param: i32) -> i32 { param + 1 }
|
Loading…
Add table
Add a link
Reference in a new issue