@@ -15,18 +15,11 @@ use its = syntax::parse::token::ident_to_str;
15
15
16
16
use syntax;
17
17
use syntax:: ast;
18
- use syntax:: ast_map;
19
18
use syntax:: ast_util;
20
19
use syntax:: attr;
21
20
use syntax:: attr:: AttributeMethods ;
22
21
23
- use rustc:: metadata:: cstore;
24
- use rustc:: metadata:: csearch;
25
- use rustc:: metadata:: decoder;
26
-
27
22
use std;
28
- use std:: hashmap:: HashMap ;
29
-
30
23
use doctree;
31
24
use visit_ast;
32
25
use std:: local_data;
@@ -68,44 +61,19 @@ impl<T: Clean<U>, U> Clean<~[U]> for syntax::opt_vec::OptVec<T> {
68
61
pub struct Crate {
69
62
name : ~str ,
70
63
module : Option < Item > ,
71
- externs : HashMap < ast:: CrateNum , ExternalCrate > ,
72
64
}
73
65
74
66
impl Clean < Crate > for visit_ast:: RustdocVisitor {
75
67
fn clean ( & self ) -> Crate {
76
68
use syntax:: attr:: { find_linkage_metas, last_meta_item_value_str_by_name} ;
77
- let maybe_meta = last_meta_item_value_str_by_name (
78
- find_linkage_metas ( self . attrs ) , "name" ) ;
79
- let cx = local_data:: get ( super :: ctxtkey, |x| * x. unwrap ( ) ) ;
80
-
81
- let mut externs = HashMap :: new ( ) ;
82
- do cstore:: iter_crate_data ( cx. sess . cstore ) |n, meta| {
83
- externs. insert ( n, meta. clean ( ) ) ;
84
- }
69
+ let maybe_meta = last_meta_item_value_str_by_name ( find_linkage_metas ( self . attrs ) , "name" ) ;
85
70
86
71
Crate {
87
72
name : match maybe_meta {
88
73
Some ( x) => x. to_owned ( ) ,
89
- None => fail2 ! ( "rustdoc requires a \\ #[link(name=\" foo\" )] \
90
- crate attribute") ,
74
+ None => fail2 ! ( "rustdoc_ng requires a \\ #[link(name=\" foo\" )] crate attribute" ) ,
91
75
} ,
92
76
module : Some ( self . module . clean ( ) ) ,
93
- externs : externs,
94
- }
95
- }
96
- }
97
-
98
- #[ deriving( Clone , Encodable , Decodable ) ]
99
- pub struct ExternalCrate {
100
- name : ~str ,
101
- attrs : ~[ Attribute ] ,
102
- }
103
-
104
- impl Clean < ExternalCrate > for cstore:: crate_metadata {
105
- fn clean ( & self ) -> ExternalCrate {
106
- ExternalCrate {
107
- name : self . name . to_owned ( ) ,
108
- attrs : decoder:: get_crate_attributes ( self . data ) . clean ( )
109
77
}
110
78
}
111
79
}
@@ -574,15 +542,7 @@ pub enum Type {
574
542
ResolvedPath {
575
543
path : Path ,
576
544
typarams : Option < ~[ TyParamBound ] > ,
577
- id : ast:: NodeId ,
578
- } ,
579
- /// Same as above, but only external variants
580
- ExternalPath {
581
- path : Path ,
582
- typarams : Option < ~[ TyParamBound ] > ,
583
- fqn : ~[ ~str ] ,
584
- kind : TypeKind ,
585
- crate : ast : : CrateNum ,
545
+ did : ast:: DefId
586
546
} ,
587
547
// I have no idea how to usefully use this.
588
548
TyParamBinder ( ast:: NodeId ) ,
@@ -612,14 +572,6 @@ pub enum Type {
612
572
// region, raw, other boxes, mutable
613
573
}
614
574
615
- #[ deriving( Clone , Encodable , Decodable ) ]
616
- pub enum TypeKind {
617
- TypeStruct ,
618
- TypeEnum ,
619
- TypeTrait ,
620
- TypeFunction ,
621
- }
622
-
623
575
impl Clean < Type > for ast:: Ty {
624
576
fn clean ( & self ) -> Type {
625
577
use syntax:: ast:: * ;
@@ -1147,12 +1099,26 @@ fn name_from_pat(p: &ast::Pat) -> ~str {
1147
1099
}
1148
1100
}
1149
1101
1102
+ fn remove_comment_tags ( s : & str ) -> ~str {
1103
+ if s. starts_with ( "/" ) {
1104
+ match s. slice ( 0 , 3 ) {
1105
+ & "///" => return s. slice ( 3 , s. len ( ) ) . trim ( ) . to_owned ( ) ,
1106
+ & "/**" | & "/*!" => return s. slice ( 3 , s. len ( ) - 2 ) . trim ( ) . to_owned ( ) ,
1107
+ _ => return s. trim ( ) . to_owned ( )
1108
+ }
1109
+ } else {
1110
+ return s. to_owned ( ) ;
1111
+ }
1112
+ }
1113
+
1150
1114
/// Given a Type, resolve it using the def_map
1151
1115
fn resolve_type ( path : Path , tpbs : Option < ~[ TyParamBound ] > ,
1152
1116
id : ast:: NodeId ) -> Type {
1153
- let cx = local_data:: get ( super :: ctxtkey, |x| * x. unwrap ( ) ) ;
1117
+ use syntax:: ast:: * ;
1118
+
1119
+ let dm = local_data:: get ( super :: ctxtkey, |x| * x. unwrap ( ) ) . tycx . def_map ;
1154
1120
debug2 ! ( "searching for {:?} in defmap" , id) ;
1155
- let d = match cx . tycx . def_map . find ( & id) {
1121
+ let d = match dm . find ( & id) {
1156
1122
Some ( k) => k,
1157
1123
None => {
1158
1124
let ctxt = local_data:: get ( super :: ctxtkey, |x| * x. unwrap ( ) ) ;
@@ -1162,41 +1128,28 @@ fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
1162
1128
}
1163
1129
} ;
1164
1130
1165
- let ( def_id, kind ) = match * d {
1166
- ast :: DefFn ( i, _) => ( i , TypeFunction ) ,
1167
- ast :: DefSelf ( i) | ast :: DefSelfTy ( i) => return Self ( i) ,
1168
- ast :: DefTy ( i) => ( i , TypeEnum ) ,
1169
- ast :: DefTrait ( i) => {
1131
+ let def_id = match * d {
1132
+ DefFn ( i, _) => i ,
1133
+ DefSelf ( i) | DefSelfTy ( i) => return Self ( i) ,
1134
+ DefTy ( i) => i ,
1135
+ DefTrait ( i) => {
1170
1136
debug2 ! ( "saw DefTrait in def_to_id" ) ;
1171
- ( i , TypeTrait )
1137
+ i
1172
1138
} ,
1173
- ast :: DefPrimTy ( p) => match p {
1174
- ast :: ty_str => return String ,
1175
- ast :: ty_bool => return Bool ,
1139
+ DefPrimTy ( p) => match p {
1140
+ ty_str => return String ,
1141
+ ty_bool => return Bool ,
1176
1142
_ => return Primitive ( p)
1177
1143
} ,
1178
- ast :: DefTyParam ( i, _) => return Generic ( i. node ) ,
1179
- ast :: DefStruct ( i) => ( i , TypeStruct ) ,
1180
- ast :: DefTyParamBinder ( i) => {
1144
+ DefTyParam ( i, _) => return Generic ( i. node ) ,
1145
+ DefStruct ( i) => i ,
1146
+ DefTyParamBinder ( i) => {
1181
1147
debug2 ! ( "found a typaram_binder, what is it? {}" , i) ;
1182
1148
return TyParamBinder ( i) ;
1183
1149
} ,
1184
1150
x => fail2 ! ( "resolved type maps to a weird def {:?}" , x) ,
1185
1151
} ;
1186
- if ast_util:: is_local ( def_id) {
1187
- ResolvedPath { path : path, typarams : tpbs, id : def_id. node }
1188
- } else {
1189
- let fqn = csearch:: get_item_path ( cx. tycx , def_id) ;
1190
- let fqn = fqn. move_iter ( ) . map ( |i| {
1191
- match i {
1192
- ast_map:: path_mod( id) |
1193
- ast_map:: path_name( id) |
1194
- ast_map:: path_pretty_name( id, _) => id. clean ( )
1195
- }
1196
- } ) . to_owned_vec ( ) ;
1197
- ExternalPath { path : path, typarams : tpbs, fqn : fqn, kind : kind,
1198
- crate : def_id. crate }
1199
- }
1152
+ ResolvedPath { path : path, typarams : tpbs, did : def_id }
1200
1153
}
1201
1154
1202
1155
fn resolve_use_source ( path : Path , id : ast:: NodeId ) -> ImportSource {
0 commit comments