]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: break where clauses onto their own line if they don't have enough room
authorQuietMisdreavus <bryan@icesoldier.me>
Sat, 15 Oct 2016 15:29:47 +0000 (10:29 -0500)
committerQuietMisdreavus <bryan@icesoldier.me>
Sat, 15 Oct 2016 15:29:47 +0000 (10:29 -0500)
src/librustdoc/html/format.rs
src/librustdoc/html/static/rustdoc.css

index 3b2f2430993a15cc902d851cb6330e089f7082f3..5fb99a2031fb5c1ee3f91bbf13fd7e27add6c03f 100644 (file)
@@ -208,7 +208,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clause.push_str("</span>");
             let plain = format!("{:#}", self);
             if plain.len() + pad.len() > 80 {
-                let padding = repeat("&nbsp;").take(pad.len() + 6).collect::<String>();
+                let padding = if pad.len() + 25 > 80 {
+                    clause = clause.replace("class='where'", "class='where fmt-newline'");
+                    repeat("&nbsp;").take(8).collect::<String>()
+                } else {
+                    repeat("&nbsp;").take(pad.len() + 6).collect::<String>()
+                };
                 clause = clause.replace("<br>", &format!("<br>{}", padding));
             } else {
                 clause = clause.replace("<br>", " ");
index f8133ea49cebae5b63edefd319466a3fbb98568f..3b6ffa4a462f6883173168dccf25bc4136dcf867 100644 (file)
@@ -361,9 +361,17 @@ h4 > code, h3 > code, .invisible > code {
     position: relative;
 }
 /* Shift "where ..." part of method or fn definition down a line */
-.content .method .where, .content .fn .where { display: block; }
+.content .method .where,
+.content .fn .where,
+.content .where.fmt-newline {
+    display: block;
+}
 /* Bit of whitespace to indent it */
-.content .method .where::before, .content .fn .where::before { content: '  '; }
+.content .method .where::before,
+.content .fn .where::before,
+.content .where.fmt-newline::before {
+    content: '  ';
+}
 
 .content .methods > div { margin-left: 40px; }