rustdoc: change the "In Function Signatures" to context-sensitive

* If it's just `-> a`, use "In Function Return Types"
* If it's just `a b`, use "In Function Parameters"
* Otherwise, still use "In Function Signatures"
This commit is contained in:
Michael Howell 2022-05-02 09:45:32 -07:00
parent 345a580e8d
commit 21a121332b
2 changed files with 17 additions and 5 deletions

View File

@ -1724,8 +1724,12 @@ window.initSearch = rawSearchIndex => {
makeTabHeader(2, "In Return Types", ret_returned[1]) +
"</div>";
} else {
const signatureTabTitle =
results.query.elems.length === 0 ? "In Function Return Types" :
results.query.returned.length === 0 ? "In Function Parameters" :
"In Function Signatures";
output += '<div id="titles">' +
makeTabHeader(0, "In Function Signature", ret_others[1]) +
makeTabHeader(0, signatureTabTitle, ret_others[1]) +
"</div>";
}

View File

@ -13,7 +13,7 @@ write: (".search-input", "-> String")
// Waiting for the search results to appear...
wait-for: "#titles"
assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"})
assert-text: ("#titles > button:nth-of-type(1)", "In Function Signature", STARTS_WITH)
assert-text: ("#titles > button:nth-of-type(1)", "In Function Return Types", STARTS_WITH)
// Try with a search-by-return with no results
goto: file://|DOC_PATH|/test_docs/index.html
@ -21,12 +21,20 @@ write: (".search-input", "-> Something")
// Waiting for the search results to appear...
wait-for: "#titles"
assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"})
assert-text: ("#titles > button:nth-of-type(1)", "In Function Signature", STARTS_WITH)
assert-text: ("#titles > button:nth-of-type(1)", "In Function Return Types", STARTS_WITH)
// Try with a search-by-return with no results
// Try with a search-by-parameter
goto: file://|DOC_PATH|/test_docs/index.html
write: (".search-input", "usize pattern")
// Waiting for the search results to appear...
wait-for: "#titles"
assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"})
assert-text: ("#titles > button:nth-of-type(1)", "In Function Signature", STARTS_WITH)
assert-text: ("#titles > button:nth-of-type(1)", "In Function Parameters", STARTS_WITH)
// Try with a search-by-parameter-and-return
goto: file://|DOC_PATH|/test_docs/index.html
write: (".search-input", "pattern -> str")
// Waiting for the search results to appear...
wait-for: "#titles"
assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"})
assert-text: ("#titles > button:nth-of-type(1)", "In Function Signatures", STARTS_WITH)