@@ -4,6 +4,7 @@ import markdown_writer::writer;
4
4
import markdown_writer:: writer_util;
5
5
6
6
export mk_pass;
7
+ export header_kind, header_name, header_text;
7
8
8
9
fn mk_pass ( config : config:: config ) -> pass {
9
10
mk_pass_ ( config, markdown_writer:: make_writer ( config) )
@@ -116,59 +117,73 @@ fn write_header_(ctxt: ctxt, lvl: hlvl, title: str) {
116
117
ctxt. w . write_line ( "" ) ;
117
118
}
118
119
119
- fn header_text ( doc : doc:: itemtag ) -> str {
120
- let fullpath = str:: connect ( doc. path ( ) + [ doc. name ( ) ] , "::" ) ;
120
+ fn header_kind ( doc : doc:: itemtag ) -> str {
121
121
alt doc {
122
122
doc : : modtag ( _) {
123
123
if doc. id ( ) == rustc:: syntax:: ast:: crate_node_id {
124
- header_text_ ( "Crate" , doc . name ( ) )
124
+ "Crate"
125
125
} else {
126
- header_text_ ( "Module" , fullpath )
126
+ "Module"
127
127
}
128
128
}
129
129
doc:: nmodtag ( _) {
130
- header_text_ ( "Native module" , fullpath )
130
+ "Native module"
131
131
}
132
132
doc:: fntag ( _) {
133
- header_text_ ( "Function" , doc . name ( ) )
133
+ "Function"
134
134
}
135
135
doc:: consttag ( _) {
136
- header_text_ ( "Const" , doc . name ( ) )
136
+ "Const"
137
137
}
138
138
doc:: enumtag ( _) {
139
- header_text_ ( "Enum" , doc . name ( ) )
139
+ "Enum"
140
140
}
141
141
doc:: restag ( _) {
142
- header_text_ ( "Resource" , doc . name ( ) )
142
+ "Resource"
143
143
}
144
144
doc:: ifacetag ( _) {
145
- header_text_ ( "Interface" , doc. name ( ) )
145
+ "Interface"
146
+ }
147
+ doc:: impltag ( doc) {
148
+ "Implementation"
149
+ }
150
+ doc:: tytag ( _) {
151
+ "Type"
152
+ }
153
+ }
154
+ }
155
+
156
+ fn header_name ( doc : doc:: itemtag ) -> str {
157
+ let fullpath = str:: connect ( doc. path ( ) + [ doc. name ( ) ] , "::" ) ;
158
+ alt doc {
159
+ doc : : modtag ( _) if doc. id ( ) != rustc:: syntax:: ast:: crate_node_id {
160
+ fullpath
161
+ }
162
+ doc:: nmodtag ( _) {
163
+ fullpath
146
164
}
147
165
doc:: impltag ( doc) {
148
166
assert option:: is_some ( doc. self_ty ) ;
149
167
let self_ty = option:: get ( doc. self_ty ) ;
150
168
alt doc. iface_ty {
151
169
some ( iface_ty) {
152
- header_text_ (
153
- "Implementation" ,
154
- #fmt ( "%s of %s for %s" ,
155
- doc. name ( ) , iface_ty, self_ty)
156
- )
170
+ #fmt ( "%s of %s for %s" , doc. name ( ) , iface_ty, self_ty)
157
171
}
158
172
none {
159
- header_text_(
160
- "Implementation" ,
161
- #fmt ( "%s for %s" , doc. name ( ) , self_ty)
162
- )
173
+ #fmt( "%s for %s" , doc. name ( ) , self_ty)
163
174
}
164
175
}
165
176
}
166
- doc :: tytag ( _ ) {
167
- header_text_ ( "Type" , doc. name ( ) )
177
+ _ {
178
+ doc. name ( )
168
179
}
169
180
}
170
181
}
171
182
183
+ fn header_text ( doc : doc:: itemtag ) -> str {
184
+ header_text_ ( header_kind ( doc) , header_name ( doc) )
185
+ }
186
+
172
187
fn header_text_ ( kind : str , name : str ) -> str {
173
188
#fmt ( "%s `%s`" , kind, name)
174
189
}
0 commit comments