]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #39740 - jimmycuadra:rustdoc-empty-stability, r=aturon
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sun, 12 Feb 2017 18:16:31 +0000 (19:16 +0100)
committerGitHub <noreply@github.com>
Sun, 12 Feb 2017 18:16:31 +0000 (19:16 +0100)
rustdoc: Only include a stability span if needed.

This patch gets rid of the empty stability boxes in docs by only including the span that creates it when the item actually has a stability class.

Here are images of the issue on `std::process::Output`:

Before:

<img width="340" alt="before" src="https://cloud.githubusercontent.com/assets/122457/22853638/ff88d1b2-f010-11e6-90d6-bf3d10e2fffa.png">

After:

<img width="333" alt="after" src="https://cloud.githubusercontent.com/assets/122457/22853639/06bfe7cc-f011-11e6-9892-f0ea2cc6ec90.png">

This is my first non-trivial patch to Rust, so I'm sure some of my approach is not idiomatic. Let me know how you'd like me to adjust!

1  2 
src/librustdoc/html/render.rs

index 75fe8cabe12cc991ac9de0f2142b54c46bc52aa5,fd83711f1f446f8016abbdda1facdd205e09c410..ae4c94d4b38c096feb09e98b92b86a48c0528ae6
@@@ -1827,10 -1827,9 +1827,10 @@@ fn item_module(w: &mut fmt::Formatter, 
                         stab_docs = stab_docs,
                         docs = shorter(Some(&Markdown(doc_value).to_string())),
                         class = myitem.type_(),
-                        stab = myitem.stability_class(),
+                        stab = myitem.stability_class().unwrap_or("".to_string()),
                         unsafety_flag = unsafety_flag,
                         href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
 +                       title_type = myitem.type_(),
                         title = full_path(cx, myitem))?;
              }
          }