-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[rustdoc] Add sub settings #60778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
[rustdoc] Add sub settings #60778
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2067,7 +2067,7 @@ if (!DOMTokenList.prototype.remove) { | |
function autoCollapse(pageId, collapse) { | ||
if (collapse) { | ||
toggleAllDocs(pageId, true); | ||
} else if (getCurrentValue("rustdoc-trait-implementations") !== "false") { | ||
} else if (getCurrentValue("rustdoc-auto-hide-trait-implementations") !== "false") { | ||
var impl_list = document.getElementById("implementations-list"); | ||
|
||
if (impl_list !== null) { | ||
|
@@ -2105,7 +2105,7 @@ if (!DOMTokenList.prototype.remove) { | |
} | ||
|
||
var toggle = createSimpleToggle(false); | ||
var hideMethodDocs = getCurrentValue("rustdoc-method-docs") === "true"; | ||
var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true"; | ||
var pageId = getPageId(); | ||
|
||
var func = function(e) { | ||
|
@@ -2235,7 +2235,31 @@ if (!DOMTokenList.prototype.remove) { | |
return wrapper; | ||
} | ||
|
||
var showItemDeclarations = getCurrentValue("rustdoc-item-declarations") === "false"; | ||
var currentType = document.getElementsByClassName("type-decl")[0]; | ||
var className = null; | ||
if (currentType) { | ||
currentType = currentType.getElementsByClassName("rust")[0]; | ||
if (currentType) { | ||
currentType.classList.forEach(function(item) { | ||
if (item !== "main") { | ||
className = item; | ||
return true; | ||
} | ||
}); | ||
} | ||
} | ||
var showItemDeclarations = getCurrentValue("rustdoc-auto-hide-" + className); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohhh, now i see why changing the names of the keys could be worthwhile. This might negate the previous comment. |
||
if (showItemDeclarations === null) { | ||
if (className === "enum" || className === "macro") { | ||
showItemDeclarations = "false"; | ||
} else if (className === "struct" || className === "union" || className === "trait") { | ||
showItemDeclarations = "true"; | ||
} else { | ||
// In case we found an unknown type, we just use the "parent" value. | ||
showItemDeclarations = getCurrentValue("rustdoc-auto-hide-declarations"); | ||
} | ||
} | ||
showItemDeclarations = showItemDeclarations === "false"; | ||
function buildToggleWrapper(e) { | ||
if (hasClass(e, "autohide")) { | ||
var wrap = e.previousElementSibling; | ||
|
@@ -2318,7 +2342,7 @@ if (!DOMTokenList.prototype.remove) { | |
|
||
// To avoid checking on "rustdoc-item-attributes" value on every loop... | ||
var itemAttributesFunc = function() {}; | ||
if (getCurrentValue("rustdoc-item-attributes") !== "false") { | ||
if (getCurrentValue("rustdoc-auto-hide-attributes") !== "false") { | ||
itemAttributesFunc = function(x) { | ||
collapseDocs(x.previousSibling.childNodes[0], "toggle"); | ||
}; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be aware that by changing the local storage keys that we look up, we're creating a situation on docs.rs (and sites like it that host docs made by multiple versions of rustdoc) where a setting made on one set of docs won't affect the other. Since we're adding a bunch more at the same time, it might be an understandable/okay change, but i'm not sure it's totally worthwhile.
Another problem with renaming existing local storage keys is that if someone had changed the setting, now they will be stuck with the default again and will need to go back and change. Should we try to have a kind of compatibility check that loads in a value from the previous key if the new one isn't set?