@@ -2322,8 +2322,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
23222322 if let Some ( ref name) = item. name {
23232323 info ! ( "Documenting {}" , name) ;
23242324 }
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 ) ?;
23272327 Ok ( ( ) )
23282328}
23292329
@@ -2332,44 +2332,53 @@ fn render_markdown(w: &mut fmt::Formatter,
23322332 cx : & Context ,
23332333 md_text : & str ,
23342334 links : Vec < ( String , String ) > ,
2335- prefix : & str )
2335+ prefix : & str ,
2336+ is_hidden : bool )
23362337 -> fmt:: Result {
23372338 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) )
23402344}
23412345
23422346fn 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 {
23442348 if let Some ( s) = item. doc_value ( ) {
23452349 let markdown = if s. contains ( '\n' ) {
23462350 format ! ( "{} [Read more]({})" ,
23472351 & plain_summary_line( Some ( s) ) , naive_assoc_href( item, link) )
23482352 } else {
23492353 plain_summary_line ( Some ( s) )
23502354 } ;
2351- render_markdown ( w, cx, & markdown, item. links ( ) , prefix) ?;
2355+ render_markdown ( w, cx, & markdown, item. links ( ) , prefix, is_hidden ) ?;
23522356 } 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) ?;
23542360 }
23552361 Ok ( ( ) )
23562362}
23572363
23582364fn 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 {
23602366 if let Some ( s) = cx. shared . maybe_collapsed_doc_value ( item) {
23612367 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 ) ?;
23632369 } 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) ?;
23652373 }
23662374 Ok ( ( ) )
23672375}
23682376
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 {
23702379 let stabilities = short_stability ( item, cx, true ) ;
23712380 if !stabilities. is_empty ( ) {
2372- write ! ( w, "<div class='stability'>" ) ?;
2381+ write ! ( w, "<div class='stability{} '>" , if is_hidden { " hidden" } else { "" } ) ?;
23732382 for stability in stabilities {
23742383 write ! ( w, "{}" , stability) ?;
23752384 }
@@ -3934,14 +3943,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
39343943 RenderMode :: ForDeref { mut_ : deref_mut_ } => should_render_item ( & item, deref_mut_) ,
39353944 } ;
39363945
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+ } ;
39373953 match item. inner {
39383954 clean:: MethodItem ( clean:: Method { ref decl, .. } ) |
3939- clean:: TyMethodItem ( clean:: TyMethod { ref decl, .. } ) => {
3955+ clean:: TyMethodItem ( clean:: TyMethod { ref decl, .. } ) => {
39403956 // Only render when the method is not static or we allow static methods
39413957 if render_method_item {
39423958 let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
39433959 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 ) ?;
39453961 write ! ( w, "{}" , spotlight_decl( decl) ?) ?;
39463962 write ! ( w, "<span id='{}' class='invisible'>" , ns_id) ?;
39473963 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
39633979 clean:: TypedefItem ( ref tydef, _) => {
39643980 let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: AssociatedType , name) ) ;
39653981 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 ) ?;
39673983 write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
39683984 assoc_type ( w, item, & Vec :: new ( ) , Some ( & tydef. type_ ) , link. anchor ( & id) ) ?;
39693985 write ! ( w, "</code></span></h4>\n " ) ?;
39703986 }
39713987 clean:: AssociatedConstItem ( ref ty, ref default) => {
39723988 let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
39733989 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 ) ?;
39753991 write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
39763992 assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) ) ?;
39773993 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
39854001 clean:: AssociatedTypeItem ( ref bounds, ref default) => {
39864002 let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
39874003 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 ) ?;
39894005 write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
39904006 assoc_type ( w, item, bounds, default. as_ref ( ) , link. anchor ( & id) ) ?;
39914007 write ! ( w, "</code></span></h4>\n " ) ?;
@@ -4002,25 +4018,25 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
40024018 if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
40034019 // We need the stability of the item from the trait
40044020 // because impls can't have a stability.
4005- document_stability ( w, cx, it) ?;
4021+ document_stability ( w, cx, it, is_hidden ) ?;
40064022 if item. doc_value ( ) . is_some ( ) {
4007- document_full ( w, item, cx, "" ) ?;
4023+ document_full ( w, item, cx, "" , is_hidden ) ?;
40084024 } else if show_def_docs {
40094025 // In case the item isn't documented,
40104026 // provide short documentation from the trait.
4011- document_short ( w, cx, it, link, "" ) ?;
4027+ document_short ( w, cx, it, link, "" , is_hidden ) ?;
40124028 }
40134029 }
40144030 } else {
4015- document_stability ( w, cx, item) ?;
4031+ document_stability ( w, cx, item, is_hidden ) ?;
40164032 if show_def_docs {
4017- document_full ( w, item, cx, "" ) ?;
4033+ document_full ( w, item, cx, "" , is_hidden ) ?;
40184034 }
40194035 }
40204036 } else {
4021- document_stability ( w, cx, item) ?;
4037+ document_stability ( w, cx, item, is_hidden ) ?;
40224038 if show_def_docs {
4023- document_short ( w, cx, item, link, "" ) ?;
4039+ document_short ( w, cx, item, link, "" , is_hidden ) ?;
40244040 }
40254041 }
40264042 }
0 commit comments