File tree 2 files changed +32
-16
lines changed
2 files changed +32
-16
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,21 @@ impl Item {
152
152
return None ;
153
153
}
154
154
155
+ pub fn is_hidden_from_doc ( & self ) -> bool {
156
+ match self . doc_list ( ) {
157
+ Some ( ref l) => {
158
+ for innerattr in l. iter ( ) {
159
+ match * innerattr {
160
+ Word ( ref s) if "hidden" == * s => return true ,
161
+ _ => ( ) ,
162
+ }
163
+ }
164
+ } ,
165
+ None => ( )
166
+ }
167
+ return false ;
168
+ }
169
+
155
170
pub fn is_mod ( & self ) -> bool {
156
171
match self . inner { ModuleItem ( ..) => true , _ => false }
157
172
}
@@ -736,7 +751,7 @@ impl Clean<Type> for ast::Ty {
736
751
737
752
#[ deriving( Clone , Encodable , Decodable ) ]
738
753
pub enum StructField {
739
- HiddenStructField ,
754
+ HiddenStructField , // inserted later by strip passes
740
755
TypedStructField ( Type ) ,
741
756
}
742
757
Original file line number Diff line number Diff line change @@ -33,23 +33,24 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
33
33
} ;
34
34
impl < ' a > fold:: DocFolder for Stripper < ' a > {
35
35
fn fold_item ( & mut self , i : Item ) -> Option < Item > {
36
- for attr in i . attrs . iter ( ) {
37
- match attr {
38
- & clean :: List ( ref x , ref l ) if "doc" == * x => {
39
- for innerattr in l . iter ( ) {
40
- match innerattr {
41
- & clean :: Word ( ref s ) if "hidden" == * s => {
42
- debug ! ( "found one in strip_hidden; removing" ) ;
43
- self . stripped . insert ( i . id ) ;
44
- return None ;
45
- } ,
46
- _ => ( ) ,
47
- }
48
- }
49
- } ,
50
- _ => ( )
36
+ if i . is_hidden_from_doc ( ) {
37
+ debug ! ( "found one in strip_hidden; removing" ) ;
38
+ self . stripped . insert ( i . id ) ;
39
+
40
+ // use a dedicated hidden item for given item type if any
41
+ match i . inner {
42
+ clean :: StructFieldItem ( .. ) => {
43
+ return Some ( clean :: Item {
44
+ inner : clean :: StructFieldItem ( clean :: HiddenStructField ) ,
45
+ ..i
46
+ } ) ;
47
+ }
48
+ _ => {
49
+ return None ;
50
+ }
51
51
}
52
52
}
53
+
53
54
self . fold_item_recur ( i)
54
55
}
55
56
}
You can’t perform that action at this time.
0 commit comments