-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Change search "not found" links #142867
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
base: master
Are you sure you want to change the base?
Change search "not found" links #142867
Conversation
The job Click to see the possible cause of the failure (guessed by this bot)
|
@@ -4919,11 +4919,12 @@ ${item.displayPath}<span class="${type}">${name}</span>\ | |||
}); | |||
} else if (query.error === null) { | |||
const dlroChannel = `https://doc.rust-lang.org/${getVar("channel")}`; | |||
const docsrsURL = `https://docs.rs/releases/search?query=${encodeURIComponent(query.userQuery)}`; | |||
const duckduckgoURL = `https://duckduckgo.com/?q=${encodeURIComponent("rust " + query.userQuery)}`; |
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.
const duckduckgoURL = `https://duckduckgo.com/?q=${encodeURIComponent("rust " + query.userQuery)}`; | |
const duckduckgoURL = `https://duckduckgo.com/?q=${encodeURIComponent("rust lang " + query.userQuery)}`; |
While we're here we should probably disambiguate so people don't get results about the game (this happens to me sometimes)
output.innerHTML = `No results in <code>${getVar("current-crate")}</code> :(<br/>` + | ||
`Search for <a href="${docsrsURL}">other crates</a>?<br/>` + | ||
`Or try on <a href="${duckduckgoURL}">DuckDuckGo</a>?<br/><br/>` + |
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.
we can apply some simple heuristics to hide this when it would be unhelpful. for example, if query.hasReturnArrow
is true, we're doing type-based search, like u8 -> u16
, which probably won't give much help.
This PR adds an additional link to the not found section on the search page in the rustdoc output. This new link points to
https://docs.rs/releases/search?q=*input*
.The use case is that I keep going to find an external item when unintentionally on https://doc.rust-lang.org/stable/std/. This provides a quicker way to where I actually want to search
docs.rs
.This also shows the current crate name in the section to remind the user what crate is being searched.
A concern is that the
docs.rs
search is by crate name, not by actual items. Maybe the message should beSearch crates matching *query*