@@ -1428,6 +1428,8 @@ impl<'a> fmt::Show for Item<'a> {
1428
1428
clean:: TypedefItem ( ref t) => item_typedef ( fmt, self . item , t) ,
1429
1429
clean:: MacroItem ( ref m) => item_macro ( fmt, self . item , m) ,
1430
1430
clean:: PrimitiveItem ( ref p) => item_primitive ( fmt, self . item , p) ,
1431
+ clean:: StaticItem ( ref i) => item_static ( fmt, self . item , i) ,
1432
+ clean:: ConstantItem ( ref c) => item_constant ( fmt, self . item , c) ,
1431
1433
_ => Ok ( ( ) )
1432
1434
}
1433
1435
}
@@ -1453,13 +1455,6 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
1453
1455
return s
1454
1456
}
1455
1457
1456
- fn blank < ' a > ( s : Option < & ' a str > ) -> & ' a str {
1457
- match s {
1458
- Some ( s) => s,
1459
- None => ""
1460
- }
1461
- }
1462
-
1463
1458
fn shorter < ' a > ( s : Option < & ' a str > ) -> & ' a str {
1464
1459
match s {
1465
1460
Some ( s) => match s. find_str ( "\n \n " ) {
@@ -1570,66 +1565,18 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1570
1565
id = short, name = name) ) ;
1571
1566
}
1572
1567
1573
- struct Initializer < ' a > ( & ' a str , Item < ' a > ) ;
1574
- impl < ' a > fmt:: Show for Initializer < ' a > {
1575
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1576
- let Initializer ( s, item) = * self ;
1577
- if s. len ( ) == 0 { return Ok ( ( ) ) ; }
1578
- try!( write ! ( f, "<code> = </code>" ) ) ;
1579
- if s. contains ( "\n " ) {
1580
- match item. href ( ) {
1581
- Some ( url) => {
1582
- write ! ( f, "<a href='{}'>[definition]</a>" ,
1583
- url)
1584
- }
1585
- None => Ok ( ( ) ) ,
1586
- }
1587
- } else {
1588
- write ! ( f, "<code>{}</code>" , s. as_slice( ) )
1589
- }
1590
- }
1591
- }
1592
-
1593
1568
match myitem. inner {
1594
- clean:: StaticItem ( ref s) | clean:: ForeignStaticItem ( ref s) => {
1595
- try!( write ! ( w, "
1596
- <tr>
1597
- <td>{}<code>{}static {}{}: {}</code>{}</td>
1598
- <td class='docblock'>{} </td>
1599
- </tr>
1600
- " ,
1601
- ConciseStability ( & myitem. stability) ,
1602
- VisSpace ( myitem. visibility) ,
1603
- MutableSpace ( s. mutability) ,
1604
- * myitem. name. as_ref( ) . unwrap( ) ,
1605
- s. type_,
1606
- Initializer ( s. expr. as_slice( ) , Item { cx: cx, item: myitem } ) ,
1607
- Markdown ( blank( myitem. doc_value( ) ) ) ) ) ;
1608
- }
1609
- clean:: ConstantItem ( ref s) => {
1610
- try!( write ! ( w, "
1611
- <tr>
1612
- <td>{}<code>{}const {}: {}</code>{}</td>
1613
- <td class='docblock'>{} </td>
1614
- </tr>
1615
- " ,
1616
- ConciseStability ( & myitem. stability) ,
1617
- VisSpace ( myitem. visibility) ,
1618
- * myitem. name. as_ref( ) . unwrap( ) ,
1619
- s. type_,
1620
- Initializer ( s. expr. as_slice( ) , Item { cx: cx, item: myitem } ) ,
1621
- Markdown ( blank( myitem. doc_value( ) ) ) ) ) ;
1622
- }
1623
-
1624
1569
clean:: ViewItemItem ( ref item) => {
1625
1570
match item. inner {
1626
1571
clean:: ExternCrate ( ref name, ref src, _) => {
1627
- try!( write ! ( w, "<tr><td><code>extern crate {}" ,
1628
- name. as_slice( ) ) ) ;
1629
1572
match * src {
1630
- Some ( ref src) => try!( write ! ( w, " = \" {}\" " ,
1631
- src. as_slice( ) ) ) ,
1632
- None => { }
1573
+ Some ( ref src) =>
1574
+ try!( write ! ( w, "<tr><td><code>extern crate \" {}\" as {}" ,
1575
+ src. as_slice( ) ,
1576
+ name. as_slice( ) ) ) ,
1577
+ None =>
1578
+ try!( write ! ( w, "<tr><td><code>extern crate {}" ,
1579
+ name. as_slice( ) ) ) ,
1633
1580
}
1634
1581
try!( write ! ( w, ";</code></td></tr>" ) ) ;
1635
1582
}
@@ -1665,6 +1612,39 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1665
1612
write ! ( w, "</table>" )
1666
1613
}
1667
1614
1615
+ struct Initializer < ' a > ( & ' a str ) ;
1616
+ impl < ' a > fmt:: Show for Initializer < ' a > {
1617
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1618
+ let Initializer ( s) = * self ;
1619
+ if s. len ( ) == 0 { return Ok ( ( ) ) ; }
1620
+ try!( write ! ( f, "<code> = </code>" ) ) ;
1621
+ write ! ( f, "<code>{}</code>" , s. as_slice( ) )
1622
+ }
1623
+ }
1624
+
1625
+ fn item_constant ( w : & mut fmt:: Formatter , it : & clean:: Item ,
1626
+ c : & clean:: Constant ) -> fmt:: Result {
1627
+ try!( write ! ( w, "<pre class='rust const'>{vis}const \
1628
+ {name}: {typ}{init}</pre>",
1629
+ vis = VisSpace ( it. visibility) ,
1630
+ name = it. name. as_ref( ) . unwrap( ) . as_slice( ) ,
1631
+ typ = c. type_,
1632
+ init = Initializer ( c. expr. as_slice( ) ) ) ) ;
1633
+ document ( w, it)
1634
+ }
1635
+
1636
+ fn item_static ( w : & mut fmt:: Formatter , it : & clean:: Item ,
1637
+ s : & clean:: Static ) -> fmt:: Result {
1638
+ try!( write ! ( w, "<pre class='rust static'>{vis}static {mutability}\
1639
+ {name}: {typ}{init}</pre>",
1640
+ vis = VisSpace ( it. visibility) ,
1641
+ mutability = MutableSpace ( s. mutability) ,
1642
+ name = it. name. as_ref( ) . unwrap( ) . as_slice( ) ,
1643
+ typ = s. type_,
1644
+ init = Initializer ( s. expr. as_slice( ) ) ) ) ;
1645
+ document ( w, it)
1646
+ }
1647
+
1668
1648
fn item_function ( w : & mut fmt:: Formatter , it : & clean:: Item ,
1669
1649
f : & clean:: Function ) -> fmt:: Result {
1670
1650
try!( write ! ( w, "<pre class='rust fn'>{vis}{fn_style}fn \
0 commit comments