diff options
Diffstat (limited to 'src/librustdoc/html/format.rs')
| -rw-r--r-- | src/librustdoc/html/format.rs | 201 |
1 files changed, 197 insertions, 4 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index abc669729fe..b24e7a7a4cf 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -10,7 +10,7 @@ //! HTML formatting module //! -//! This module contains a large number of `fmt::Show` implementations for +//! This module contains a large number of `fmt::String` implementations for //! various types in `rustdoc::clean`. These implementations all currently //! assume that HTML output is desired, although it may be possible to redesign //! them in the future to instead emit any format desired. @@ -64,8 +64,16 @@ impl UnsafetySpace { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl<'a> fmt::Show for TyParamBounds<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl<'a> fmt::String for TyParamBounds<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &TyParamBounds(bounds) = self; for (i, bound) in bounds.iter().enumerate() { if i > 0 { @@ -77,7 +85,15 @@ impl<'a> fmt::Show for TyParamBounds<'a> { } } -impl fmt::Show for clean::Generics { +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] +impl fmt::Show for clean::Generic { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::Generics { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.lifetimes.len() == 0 && self.type_params.len() == 0 { return Ok(()) } try!(f.write_str("<")); @@ -114,8 +130,16 @@ impl fmt::Show for clean::Generics { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl<'a> fmt::Show for WhereClause<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl<'a> fmt::String for WhereClause<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &WhereClause(gens) = self; if gens.where_predicates.len() == 0 { return Ok(()); @@ -151,15 +175,31 @@ impl<'a> fmt::Show for WhereClause<'a> { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::Lifetime { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::Lifetime { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(f.write_str(self.get_ref())); Ok(()) } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::PolyTrait { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::PolyTrait { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.lifetimes.len() > 0 { try!(f.write_str("for<")); for (i, lt) in self.lifetimes.iter().enumerate() { @@ -174,8 +214,16 @@ impl fmt::Show for clean::PolyTrait { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::TyParamBound { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::TyParamBound { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { clean::RegionBound(ref lt) => { write!(f, "{}", *lt) @@ -191,8 +239,16 @@ impl fmt::Show for clean::TyParamBound { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::PathParameters { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::PathParameters { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { clean::PathParameters::AngleBracketed { ref lifetimes, ref types } => { if lifetimes.len() > 0 || types.len() > 0 { @@ -236,15 +292,31 @@ impl fmt::Show for clean::PathParameters { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::PathSegment { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::PathSegment { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(f.write_str(self.name.as_slice())); write!(f, "{}", self.params) } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::Path { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.global { try!(f.write_str("::")) } @@ -429,8 +501,16 @@ fn tybounds(w: &mut fmt::Formatter, } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::Type { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::Type { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { clean::TyParamBinder(id) => { f.write_str(cache().typarams[ast_util::local_def(id)].as_slice()) @@ -570,8 +650,17 @@ impl fmt::Show for clean::Type { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::Arguments { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + + +impl fmt::String for clean::Arguments { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { for (i, input) in self.values.iter().enumerate() { if i > 0 { try!(write!(f, ", ")); } if input.name.len() > 0 { @@ -583,8 +672,16 @@ impl fmt::Show for clean::Arguments { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::FunctionRetTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::FunctionRetTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()), clean::Return(ref ty) => write!(f, " -> {}", ty), @@ -593,14 +690,30 @@ impl fmt::Show for clean::FunctionRetTy { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::FnDecl { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::FnDecl { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output) } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl<'a> fmt::Show for Method<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl<'a> fmt::String for Method<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Method(selfty, d) = *self; let mut args = String::new(); match *selfty { @@ -629,8 +742,16 @@ impl<'a> fmt::Show for Method<'a> { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for VisSpace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for VisSpace { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.get() { Some(ast::Public) => write!(f, "pub "), Some(ast::Inherited) | None => Ok(()) @@ -638,8 +759,16 @@ impl fmt::Show for VisSpace { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for UnsafetySpace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for UnsafetySpace { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.get() { ast::Unsafety::Unsafe => write!(f, "unsafe "), ast::Unsafety::Normal => Ok(()) @@ -647,8 +776,16 @@ impl fmt::Show for UnsafetySpace { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::ViewPath { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::ViewPath { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { clean::SimpleImport(ref name, ref src) => { if *name == src.path.segments.last().unwrap().name { @@ -674,8 +811,16 @@ impl fmt::Show for clean::ViewPath { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::ImportSource { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::ImportSource { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.did { Some(did) => resolved_path(f, did, &self.path, true), _ => { @@ -691,8 +836,16 @@ impl fmt::Show for clean::ImportSource { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for clean::ViewListIdent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for clean::ViewListIdent { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.source { Some(did) => { let path = clean::Path { @@ -712,8 +865,16 @@ impl fmt::Show for clean::ViewListIdent { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for MutableSpace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for MutableSpace { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { MutableSpace(clean::Immutable) => Ok(()), MutableSpace(clean::Mutable) => write!(f, "mut "), @@ -721,8 +882,16 @@ impl fmt::Show for MutableSpace { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for RawMutableSpace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for RawMutableSpace { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { RawMutableSpace(clean::Immutable) => write!(f, "const "), RawMutableSpace(clean::Mutable) => write!(f, "mut "), @@ -730,13 +899,21 @@ impl fmt::Show for RawMutableSpace { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl<'a> fmt::Show for Stability<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl<'a> fmt::String for Stability<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Stability(stab) = *self; match *stab { Some(ref stability) => { write!(f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>", - lvl = stability.level.to_string(), + lvl = stability.level, reason = stability.text) } None => Ok(()) @@ -744,13 +921,21 @@ impl<'a> fmt::Show for Stability<'a> { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl<'a> fmt::Show for ConciseStability<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl<'a> fmt::String for ConciseStability<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let ConciseStability(stab) = *self; match *stab { Some(ref stability) => { write!(f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>", - lvl = stability.level.to_string(), + lvl = stability.level, colon = if stability.text.len() > 0 { ": " } else { "" }, reason = stability.text) } @@ -761,8 +946,16 @@ impl<'a> fmt::Show for ConciseStability<'a> { } } +//NOTE(stage0): remove impl after snapshot +#[cfg(stage0)] impl fmt::Show for ModuleSummary { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for ModuleSummary { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt_inner<'a>(f: &mut fmt::Formatter, context: &mut Vec<&'a str>, m: &'a ModuleSummary) |
