Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
kaleidawave wants to merge 2 commits into rust-lang:master
base: master
Choose a base branch
Loading
from kaleidawave:rust-doc-add-link-to-docs-rs

Conversation

Copy link

@kaleidawave kaleidawave commented Jun 22, 2025

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 be Search crates matching *query*

@rustbot rustbot added A-rustdoc-search Area: Rustdoc's search feature T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 22, 2025
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Checking tidy rustdoc_json...
Running eslint on rustdoc JS files
/checkout/src/librustdoc/html/static/js/search.js
 4922:1 error This line has a length of 105. Maximum allowed is 100 max-len
 4923:1 error This line has a length of 107. Maximum allowed is 100 max-len
✖ 2 problems (2 errors, 0 warnings)
eslint command failed
`rustdoc-json-types` was not modified.
tidy: Skipping binary file check, read-only filesystem
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:4922: line longer than 100 chars
##[error]tidy error: /checkout/src/librustdoc/html/static/js/search.js:4923: line longer than 100 chars
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (25.1.1)
linting python files
All checks passed!
checking python file formatting
28 files already formatted
checking C++ file formatting
some tidy checks failed
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:21
 local time: Sun Jun 22 09:39:11 UTC 2025
 network time: 2025年6月22日 09:39:11 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@@ -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)}`;
Copy link
Contributor

@lolbinarycat lolbinarycat Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Comment on lines +4925 to +4927
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/>` +
Copy link
Contributor

@lolbinarycat lolbinarycat Jun 23, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@lolbinarycat lolbinarycat lolbinarycat left review comments

Assignees
No one assigned
Labels
A-rustdoc-search Area: Rustdoc's search feature T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /