]> git.lizzy.rs Git - rust.git/commitdiff
Updated wording and placement of non-exhaustive notice so it is collapsed by default...
authorDavid Wood <david@davidtw.co>
Wed, 18 Jul 2018 19:27:25 +0000 (20:27 +0100)
committerDavid Wood <david@davidtw.co>
Wed, 18 Jul 2018 19:27:25 +0000 (20:27 +0100)
src/librustdoc/html/render.rs
src/librustdoc/html/static/main.js
src/librustdoc/html/static/rustdoc.css
src/librustdoc/html/static/themes/dark.css
src/librustdoc/html/static/themes/light.css

index c344302cabf598cff0a740e223b3b3918a11ac83..78cf74571870590414e45f24187a9347dc31c0f7 100644 (file)
@@ -2268,24 +2268,26 @@ fn document_non_exhaustive_header(item: &clean::Item) -> &str {
 
 fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
     if item.is_non_exhaustive() {
-        write!(w, "<p class='non-exhaustive'>")?;
+        write!(w, "<div class='docblock non-exhaustive non-exhaustive-{}'>", {
+            if item.is_struct() { "struct" } else if item.is_enum() { "enum" } else { "type" }
+        })?;
 
         if item.is_struct() {
-            write!(w, "This struct is marked as non-exhaustive as additional fields may be \
-                       added in the future. This means that this struct cannot be constructed in \
-                       external crates using the traditional <code>Struct {{ .. }}</code> syntax;
-                       cannot be matched against without a wildcard <code>..</code>; and \
-                       functional-record-updates do not work on this struct.")?;
+            write!(w, "Non-exhaustive structs could have additional fields added in future. \
+                       Therefore, non-exhaustive structs cannot be constructed in external crates \
+                       using the traditional <code>Struct {{ .. }}</code> syntax; cannot be \
+                       matched against without a wildcard <code>..</code>; and \
+                       functional-record-updates do not work.")?;
         } else if item.is_enum() {
-            write!(w, "This enum is marked as non-exhaustive, and additional variants may be \
-                       added in the future. When matching over values of this type, an extra \
-                       <code>_</code> arm must be added to account for future extensions.")?;
+            write!(w, "Non-exhaustive enums could have additional variants added in future. \
+                       Therefore, when matching against variants of non-exhaustive enums, an \
+                       extra wildcard arm must be added to account for any future variants.")?;
         } else {
             write!(w, "This type will require a wildcard arm in any match statements or \
                        constructors.")?;
         }
 
-        write!(w, "</p>")?;
+        write!(w, "</div>")?;
     }
 
     Ok(())
index bb996e00d352abfe586884082ceb33beb4051530..af994229edf30512bbb3549190a61ff2f89bfeb5 100644 (file)
         onEach(e.getElementsByClassName('associatedconstant'), func);
     });
 
-    function createToggle(otherMessage, extraClass) {
+    function createToggle(otherMessage, fontSize, extraClass) {
         var span = document.createElement('span');
         span.className = 'toggle-label';
         span.style.display = 'none';
             span.innerHTML = '&nbsp;Expand&nbsp;description';
         } else {
             span.innerHTML = otherMessage;
-            span.style.fontSize = '20px';
+        }
+
+        if (fontSize) {
+            span.style.fontSize = fontSize;
         }
 
         var mainToggle = toggle.cloneNode(true);
         }
         if (e.parentNode.id === "main") {
             var otherMessage;
+            var fontSize;
             var extraClass;
+
             if (hasClass(e, "type-decl")) {
+                fontSize = "20px";
                 otherMessage = '&nbsp;Show&nbsp;declaration';
+            } else if (hasClass(e, "non-exhaustive")) {
+                otherMessage = '&nbsp;This&nbsp;';
+                if (hasClass(e, "non-exhaustive-struct")) {
+                    otherMessage += 'struct';
+                } else if (hasClass(e, "non-exhaustive-enum")) {
+                    otherMessage += 'enum';
+                } else if (hasClass(e, "non-exhaustive-type")) {
+                    otherMessage += 'type';
+                }
+                otherMessage += '&nbsp;is&nbsp;marked&nbsp;as&nbsp;non-exhaustive';
             } else if (hasClass(e.childNodes[0], "impl-items")) {
                 extraClass = "marg-left";
             }
-            e.parentNode.insertBefore(createToggle(otherMessage, extraClass), e);
+
+            e.parentNode.insertBefore(createToggle(otherMessage, fontSize, extraClass), e);
             if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
                 collapseDocs(e.previousSibling.childNodes[0], "toggle");
             }
index 575a7ea27921f0e9581e4276f30ce6ec2311a1ae..b689e2fa3854e3608f2344b8f8ebd7ab4e745891 100644 (file)
@@ -1358,4 +1358,8 @@ kbd {
 }
 #all-types > p {
        margin: 5px 0;
-}
\ No newline at end of file
+}
+
+.non-exhaustive {
+       margin-bottom: 1em;
+}
index f97ff45b22f7a715d45b3c8b25840002773582cc..3aea30c767f61f5902e7465c910614f1a91ac0da 100644 (file)
@@ -148,8 +148,6 @@ pre {
 .content .fnname{ color: #2BAB63; }
 .content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
 
-.non-exhaustive { color: #DDD; margin-bottom: 1em; }
-
 pre.rust .comment { color: #8d8d8b; }
 pre.rust .doccomment { color: #8ca375; }
 
index da8b24f3b171f45e37803952399255cd6cef276b..e84e3cb56636e485048b3be7d856e3225f47e891 100644 (file)
@@ -148,8 +148,6 @@ pre {
 .content .fnname { color: #9a6e31; }
 .content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
 
-.non-exhaustive { color: #222; margin-bottom: 1em; }
-
 pre.rust .comment { color: #8E908C; }
 pre.rust .doccomment { color: #4D4D4C; }