@@ -1386,6 +1386,8 @@ impl<'a> fmt::Show for Item<'a> {
1386
1386
clean:: TypedefItem ( ref t) => item_typedef ( fmt, self . item , t) ,
1387
1387
clean:: MacroItem ( ref m) => item_macro ( fmt, self . item , m) ,
1388
1388
clean:: PrimitiveItem ( ref p) => item_primitive ( fmt, self . item , p) ,
1389
+ clean:: StaticItem ( ref i) => item_static ( fmt, self . item , i) ,
1390
+ clean:: ConstantItem ( ref c) => item_constant ( fmt, self . item , c) ,
1389
1391
_ => Ok ( ( ) )
1390
1392
}
1391
1393
}
@@ -1411,13 +1413,6 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
1411
1413
return s
1412
1414
}
1413
1415
1414
- fn blank < ' a > ( s : Option < & ' a str > ) -> & ' a str {
1415
- match s {
1416
- Some ( s) => s,
1417
- None => ""
1418
- }
1419
- }
1420
-
1421
1416
fn shorter < ' a > ( s : Option < & ' a str > ) -> & ' a str {
1422
1417
match s {
1423
1418
Some ( s) => match s. find_str ( "\n \n " ) {
@@ -1528,57 +1523,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1528
1523
id = short, name = name) ) ;
1529
1524
}
1530
1525
1531
- struct Initializer < ' a > ( & ' a str , Item < ' a > ) ;
1532
- impl < ' a > fmt:: Show for Initializer < ' a > {
1533
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1534
- let Initializer ( s, item) = * self ;
1535
- if s. len ( ) == 0 { return Ok ( ( ) ) ; }
1536
- try!( write ! ( f, "<code> = </code>" ) ) ;
1537
- if s. contains ( "\n " ) {
1538
- match item. href ( ) {
1539
- Some ( url) => {
1540
- write ! ( f, "<a href='{}'>[definition]</a>" ,
1541
- url)
1542
- }
1543
- None => Ok ( ( ) ) ,
1544
- }
1545
- } else {
1546
- write ! ( f, "<code>{}</code>" , s. as_slice( ) )
1547
- }
1548
- }
1549
- }
1550
-
1551
1526
match myitem. inner {
1552
- clean:: StaticItem ( ref s) | clean:: ForeignStaticItem ( ref s) => {
1553
- try!( write ! ( w, "
1554
- <tr>
1555
- <td>{}<code>{}static {}{}: {}</code>{}</td>
1556
- <td class='docblock'>{} </td>
1557
- </tr>
1558
- " ,
1559
- ConciseStability ( & myitem. stability) ,
1560
- VisSpace ( myitem. visibility) ,
1561
- MutableSpace ( s. mutability) ,
1562
- * myitem. name. as_ref( ) . unwrap( ) ,
1563
- s. type_,
1564
- Initializer ( s. expr. as_slice( ) , Item { cx: cx, item: myitem } ) ,
1565
- Markdown ( blank( myitem. doc_value( ) ) ) ) ) ;
1566
- }
1567
- clean:: ConstantItem ( ref s) => {
1568
- try!( write ! ( w, "
1569
- <tr>
1570
- <td>{}<code>{}const {}: {}</code>{}</td>
1571
- <td class='docblock'>{} </td>
1572
- </tr>
1573
- " ,
1574
- ConciseStability ( & myitem. stability) ,
1575
- VisSpace ( myitem. visibility) ,
1576
- * myitem. name. as_ref( ) . unwrap( ) ,
1577
- s. type_,
1578
- Initializer ( s. expr. as_slice( ) , Item { cx: cx, item: myitem } ) ,
1579
- Markdown ( blank( myitem. doc_value( ) ) ) ) ) ;
1580
- }
1581
-
1582
1527
clean:: ViewItemItem ( ref item) => {
1583
1528
match item. inner {
1584
1529
clean:: ExternCrate ( ref name, ref src, _) => {
@@ -1625,6 +1570,39 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1625
1570
write ! ( w, "</table>" )
1626
1571
}
1627
1572
1573
+ struct Initializer < ' a > ( & ' a str ) ;
1574
+ impl < ' a > fmt:: Show for Initializer < ' a > {
1575
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1576
+ let Initializer ( s) = * self ;
1577
+ if s. len ( ) == 0 { return Ok ( ( ) ) ; }
1578
+ try!( write ! ( f, "<code> = </code>" ) ) ;
1579
+ write ! ( f, "<code>{}</code>" , s. as_slice( ) )
1580
+ }
1581
+ }
1582
+
1583
+ fn item_constant ( w : & mut fmt:: Formatter , it : & clean:: Item ,
1584
+ c : & clean:: Constant ) -> fmt:: Result {
1585
+ try!( write ! ( w, "<pre class='rust const'>{vis}const \
1586
+ {name}: {typ}{init}</pre>",
1587
+ vis = VisSpace ( it. visibility) ,
1588
+ name = it. name. as_ref( ) . unwrap( ) . as_slice( ) ,
1589
+ typ = c. type_,
1590
+ init = Initializer ( c. expr. as_slice( ) ) ) ) ;
1591
+ document ( w, it)
1592
+ }
1593
+
1594
+ fn item_static ( w : & mut fmt:: Formatter , it : & clean:: Item ,
1595
+ s : & clean:: Static ) -> fmt:: Result {
1596
+ try!( write ! ( w, "<pre class='rust static'>{vis}static {mutability}\
1597
+ {name}: {typ}{init}</pre>",
1598
+ vis = VisSpace ( it. visibility) ,
1599
+ mutability = MutableSpace ( s. mutability) ,
1600
+ name = it. name. as_ref( ) . unwrap( ) . as_slice( ) ,
1601
+ typ = s. type_,
1602
+ init = Initializer ( s. expr. as_slice( ) ) ) ) ;
1603
+ document ( w, it)
1604
+ }
1605
+
1628
1606
fn item_function ( w : & mut fmt:: Formatter , it : & clean:: Item ,
1629
1607
f : & clean:: Function ) -> fmt:: Result {
1630
1608
try!( write ! ( w, "<pre class='rust fn'>{vis}{fn_style}fn \
0 commit comments