|
1938 | 1938 | if (collapse) {
|
1939 | 1939 | toggleAllDocs(pageId, true);
|
1940 | 1940 | }
|
1941 |
| - if (getCurrentValue('rustdoc-trait-implementations') !== "false") { |
1942 |
| - onEach(document.getElementsByClassName("collapse-toggle"), function(e) { |
| 1941 | + var collapser = function(e) { |
1943 | 1942 | // inherent impl ids are like 'impl' or impl-<number>'.
|
1944 | 1943 | // they will never be hidden by default.
|
1945 |
| - var n = e.parentNode; |
| 1944 | + var n = e.parentElement; |
1946 | 1945 | if (n.id.match(/^impl(?:-\d+)?$/) === null) {
|
1947 | 1946 | // Automatically minimize all non-inherent impls
|
1948 | 1947 | if (collapse || hasClass(n, 'impl')) {
|
1949 | 1948 | collapseDocs(e, "hide", pageId);
|
1950 | 1949 | }
|
1951 | 1950 | }
|
1952 |
| - }); |
| 1951 | + }; |
| 1952 | + if (getCurrentValue('rustdoc-trait-implementations') !== "false") { |
| 1953 | + onEach(document.getElementById('implementations-list') |
| 1954 | + .getElementsByClassName("collapse-toggle"), collapser); |
| 1955 | + } |
| 1956 | + if (getCurrentValue('rustdoc-method-docs') !== "false") { |
| 1957 | + var implItems = document.getElementsByClassName('impl-items'); |
| 1958 | + |
| 1959 | + if (implItems && implItems.length > 0) { |
| 1960 | + onEach(implItems[0].getElementsByClassName("collapse-toggle"), collapser); |
| 1961 | + } |
1953 | 1962 | }
|
1954 | 1963 | }
|
1955 | 1964 |
|
|
2001 | 2010 | onEach(e.getElementsByClassName('associatedconstant'), func);
|
2002 | 2011 | });
|
2003 | 2012 |
|
2004 |
| - function createToggle(otherMessage, fontSize, extraClass) { |
| 2013 | + function createToggle(otherMessage, fontSize, extraClass, show) { |
2005 | 2014 | var span = document.createElement('span');
|
2006 | 2015 | span.className = 'toggle-label';
|
2007 |
| - span.style.display = 'none'; |
| 2016 | + if (show) { |
| 2017 | + span.style.display = 'none'; |
| 2018 | + } |
2008 | 2019 | if (!otherMessage) {
|
2009 | 2020 | span.innerHTML = ' Expand description';
|
2010 | 2021 | } else {
|
|
2020 | 2031 |
|
2021 | 2032 | var wrapper = document.createElement('div');
|
2022 | 2033 | wrapper.className = 'toggle-wrapper';
|
| 2034 | + if (!show) { |
| 2035 | + addClass(wrapper, 'collapsed'); |
| 2036 | + var inner = mainToggle.getElementsByClassName('inner'); |
| 2037 | + if (inner && inner.length > 0) { |
| 2038 | + inner[0].innerHTML = '+'; |
| 2039 | + } |
| 2040 | + } |
2023 | 2041 | if (extraClass) {
|
2024 |
| - wrapper.className += ' ' + extraClass; |
| 2042 | + addClass(wrapper, extraClass); |
2025 | 2043 | }
|
2026 | 2044 | wrapper.appendChild(mainToggle);
|
2027 | 2045 | return wrapper;
|
|
2053 | 2071 | var otherMessage;
|
2054 | 2072 | var fontSize;
|
2055 | 2073 | var extraClass;
|
| 2074 | + var show = true; |
2056 | 2075 |
|
2057 | 2076 | if (hasClass(e, "type-decl")) {
|
2058 | 2077 | fontSize = "20px";
|
2059 | 2078 | otherMessage = ' Show declaration';
|
| 2079 | + show = getCurrentValue('rustdoc-item-declarations') === "false"; |
| 2080 | + if (!show) { |
| 2081 | + extraClass = 'collapsed'; |
| 2082 | + } |
2060 | 2083 | } else if (hasClass(e, "non-exhaustive")) {
|
2061 | 2084 | otherMessage = ' This ';
|
2062 | 2085 | if (hasClass(e, "non-exhaustive-struct")) {
|
|
2071 | 2094 | extraClass = "marg-left";
|
2072 | 2095 | }
|
2073 | 2096 |
|
2074 |
| - e.parentNode.insertBefore(createToggle(otherMessage, fontSize, extraClass), e); |
2075 |
| - if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") { |
| 2097 | + e.parentNode.insertBefore(createToggle(otherMessage, fontSize, extraClass, show), e); |
| 2098 | + if (otherMessage && show) { |
2076 | 2099 | collapseDocs(e.previousSibling.childNodes[0], "toggle");
|
2077 | 2100 | }
|
2078 | 2101 | }
|
|
0 commit comments