@@ -2322,8 +2322,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
2322
2322
if let Some ( ref name) = item. name {
2323
2323
info ! ( "Documenting {}" , name) ;
2324
2324
}
2325
- document_stability ( w, cx, item) ?;
2326
- document_full ( w, item, cx, "" ) ?;
2325
+ document_stability ( w, cx, item, false ) ?;
2326
+ document_full ( w, item, cx, "" , false ) ?;
2327
2327
Ok ( ( ) )
2328
2328
}
2329
2329
@@ -2332,44 +2332,53 @@ fn render_markdown(w: &mut fmt::Formatter,
2332
2332
cx : & Context ,
2333
2333
md_text : & str ,
2334
2334
links : Vec < ( String , String ) > ,
2335
- prefix : & str )
2335
+ prefix : & str ,
2336
+ is_hidden : bool )
2336
2337
-> fmt:: Result {
2337
2338
let mut ids = cx. id_map . borrow_mut ( ) ;
2338
- write ! ( w, "<div class='docblock'>{}{}</div>" ,
2339
- prefix, Markdown ( md_text, & links, RefCell :: new( & mut ids) , cx. codes) )
2339
+ write ! ( w, "<div class='docblock{}'>{}{}</div>" ,
2340
+ if is_hidden { " hidden" } else { "" } ,
2341
+ prefix,
2342
+ Markdown ( md_text, & links, RefCell :: new( & mut ids) ,
2343
+ cx. codes) )
2340
2344
}
2341
2345
2342
2346
fn document_short ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item , link : AssocItemLink ,
2343
- prefix : & str ) -> fmt:: Result {
2347
+ prefix : & str , is_hidden : bool ) -> fmt:: Result {
2344
2348
if let Some ( s) = item. doc_value ( ) {
2345
2349
let markdown = if s. contains ( '\n' ) {
2346
2350
format ! ( "{} [Read more]({})" ,
2347
2351
& plain_summary_line( Some ( s) ) , naive_assoc_href( item, link) )
2348
2352
} else {
2349
2353
plain_summary_line ( Some ( s) )
2350
2354
} ;
2351
- render_markdown ( w, cx, & markdown, item. links ( ) , prefix) ?;
2355
+ render_markdown ( w, cx, & markdown, item. links ( ) , prefix, is_hidden ) ?;
2352
2356
} else if !prefix. is_empty ( ) {
2353
- write ! ( w, "<div class='docblock'>{}</div>" , prefix) ?;
2357
+ write ! ( w, "<div class='docblock{}'>{}</div>" ,
2358
+ if is_hidden { " hidden" } else { "" } ,
2359
+ prefix) ?;
2354
2360
}
2355
2361
Ok ( ( ) )
2356
2362
}
2357
2363
2358
2364
fn document_full ( w : & mut fmt:: Formatter , item : & clean:: Item ,
2359
- cx : & Context , prefix : & str ) -> fmt:: Result {
2365
+ cx : & Context , prefix : & str , is_hidden : bool ) -> fmt:: Result {
2360
2366
if let Some ( s) = cx. shared . maybe_collapsed_doc_value ( item) {
2361
2367
debug ! ( "Doc block: =====\n {}\n =====" , s) ;
2362
- render_markdown ( w, cx, & * s, item. links ( ) , prefix) ?;
2368
+ render_markdown ( w, cx, & * s, item. links ( ) , prefix, is_hidden ) ?;
2363
2369
} else if !prefix. is_empty ( ) {
2364
- write ! ( w, "<div class='docblock'>{}</div>" , prefix) ?;
2370
+ write ! ( w, "<div class='docblock{}'>{}</div>" ,
2371
+ if is_hidden { " hidden" } else { "" } ,
2372
+ prefix) ?;
2365
2373
}
2366
2374
Ok ( ( ) )
2367
2375
}
2368
2376
2369
- fn document_stability ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item ) -> fmt:: Result {
2377
+ fn document_stability ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item ,
2378
+ is_hidden : bool ) -> fmt:: Result {
2370
2379
let stabilities = short_stability ( item, cx, true ) ;
2371
2380
if !stabilities. is_empty ( ) {
2372
- write ! ( w, "<div class='stability'>" ) ?;
2381
+ write ! ( w, "<div class='stability{} '>" , if is_hidden { " hidden" } else { "" } ) ?;
2373
2382
for stability in stabilities {
2374
2383
write ! ( w, "{}" , stability) ?;
2375
2384
}
@@ -3934,14 +3943,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
3934
3943
RenderMode :: ForDeref { mut_ : deref_mut_ } => should_render_item ( & item, deref_mut_) ,
3935
3944
} ;
3936
3945
3946
+ let ( is_hidden, extra_class) = if trait_. is_none ( ) ||
3947
+ item. doc_value ( ) . is_some ( ) ||
3948
+ item. inner . is_associated ( ) {
3949
+ ( false , "" )
3950
+ } else {
3951
+ ( true , " hidden" )
3952
+ } ;
3937
3953
match item. inner {
3938
3954
clean:: MethodItem ( clean:: Method { ref decl, .. } ) |
3939
- clean:: TyMethodItem ( clean:: TyMethod { ref decl, .. } ) => {
3955
+ clean:: TyMethodItem ( clean:: TyMethod { ref decl, .. } ) => {
3940
3956
// Only render when the method is not static or we allow static methods
3941
3957
if render_method_item {
3942
3958
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
3943
3959
let ns_id = cx. derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
3944
- write ! ( w, "<h4 id='{}' class=\" {}\" >" , id, item_type) ?;
3960
+ write ! ( w, "<h4 id='{}' class=\" {}{} \" >" , id, item_type, extra_class ) ?;
3945
3961
write ! ( w, "{}" , spotlight_decl( decl) ?) ?;
3946
3962
write ! ( w, "<span id='{}' class='invisible'>" , ns_id) ?;
3947
3963
write ! ( w, "<table class='table-display'><tbody><tr><td><code>" ) ?;
@@ -3963,15 +3979,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
3963
3979
clean:: TypedefItem ( ref tydef, _) => {
3964
3980
let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: AssociatedType , name) ) ;
3965
3981
let ns_id = cx. derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
3966
- write ! ( w, "<h4 id='{}' class=\" {}\" >" , id, item_type) ?;
3982
+ write ! ( w, "<h4 id='{}' class=\" {}{} \" >" , id, item_type, extra_class ) ?;
3967
3983
write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
3968
3984
assoc_type ( w, item, & Vec :: new ( ) , Some ( & tydef. type_ ) , link. anchor ( & id) ) ?;
3969
3985
write ! ( w, "</code></span></h4>\n " ) ?;
3970
3986
}
3971
3987
clean:: AssociatedConstItem ( ref ty, ref default) => {
3972
3988
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
3973
3989
let ns_id = cx. derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
3974
- write ! ( w, "<h4 id='{}' class=\" {}\" >" , id, item_type) ?;
3990
+ write ! ( w, "<h4 id='{}' class=\" {}{} \" >" , id, item_type, extra_class ) ?;
3975
3991
write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
3976
3992
assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) ) ?;
3977
3993
let src = if let Some ( l) = ( Item { cx, item } ) . src_href ( ) {
@@ -3985,7 +4001,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
3985
4001
clean:: AssociatedTypeItem ( ref bounds, ref default) => {
3986
4002
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
3987
4003
let ns_id = cx. derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
3988
- write ! ( w, "<h4 id='{}' class=\" {}\" >" , id, item_type) ?;
4004
+ write ! ( w, "<h4 id='{}' class=\" {}{} \" >" , id, item_type, extra_class ) ?;
3989
4005
write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
3990
4006
assoc_type ( w, item, bounds, default. as_ref ( ) , link. anchor ( & id) ) ?;
3991
4007
write ! ( w, "</code></span></h4>\n " ) ?;
@@ -4002,25 +4018,25 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
4002
4018
if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
4003
4019
// We need the stability of the item from the trait
4004
4020
// because impls can't have a stability.
4005
- document_stability ( w, cx, it) ?;
4021
+ document_stability ( w, cx, it, is_hidden ) ?;
4006
4022
if item. doc_value ( ) . is_some ( ) {
4007
- document_full ( w, item, cx, "" ) ?;
4023
+ document_full ( w, item, cx, "" , is_hidden ) ?;
4008
4024
} else if show_def_docs {
4009
4025
// In case the item isn't documented,
4010
4026
// provide short documentation from the trait.
4011
- document_short ( w, cx, it, link, "" ) ?;
4027
+ document_short ( w, cx, it, link, "" , is_hidden ) ?;
4012
4028
}
4013
4029
}
4014
4030
} else {
4015
- document_stability ( w, cx, item) ?;
4031
+ document_stability ( w, cx, item, is_hidden ) ?;
4016
4032
if show_def_docs {
4017
- document_full ( w, item, cx, "" ) ?;
4033
+ document_full ( w, item, cx, "" , is_hidden ) ?;
4018
4034
}
4019
4035
}
4020
4036
} else {
4021
- document_stability ( w, cx, item) ?;
4037
+ document_stability ( w, cx, item, is_hidden ) ?;
4022
4038
if show_def_docs {
4023
- document_short ( w, cx, item, link, "" ) ?;
4039
+ document_short ( w, cx, item, link, "" , is_hidden ) ?;
4024
4040
}
4025
4041
}
4026
4042
}
0 commit comments