-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc search: add new crate:
syntax to search a single crate
#129914
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @notriddle (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
This comment has been minimized.
This comment has been minimized.
This seems great! 👍 You can work around the comma thing by using an inelegant special case in the parser. diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 35ba2f50055..f02c488b530 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -283,6 +283,20 @@ function getFilteredNextElem(query, parserState, elems, isInGenerics) {
parserState.pos += 1;
parserState.totalElems -= 1;
query.literalSearch = false;
+ if (parserState.typeFilter === "crate") {
+ while (parserState.userQuery[parserState.pos] === " ") {
+ parserState.pos += 1;
+ }
+ const start = parserState.pos;
+ const foundCrate = consumeIdent(parserState);
+ if (!foundCrate) {
+ throw ["Expected ident after ", "crate:", ", found ", parserState.userQuery[start]];
+ }
+ const name = parserState.userQuery.substring(start, parserState.pos);
+ elems.push(makePrimitiveElement(name, { typeFilter: "crate" }));
+ parserState.typeFilter = null;
+ return getFilteredNextElem(query, parserState, elems, isInGenerics);
+ }
getNextElem(query, parserState, elems, isInGenerics);
}
} |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a71b3f8
to
b44fea5
Compare
@rfcbot poll |
Team member @notriddle has asked teams: T-rustdoc-frontend, for consensus on: |
I personally prefer the approach in #129769. |
@GuillaumeGomez i prefer this approach due to it not breaking existing workflows. perhaps in the future i'll add a completion menu when typing |
I think adding the possibility to filter on multiple crates and therefore allowing to repeat |
@GuillaumeGomez searching multiple crates would be nice (i think it should accept either specifying it multiple times or separated by commas, should be pretty easy to implement into the parser), however it would require more invasive changes, since the code assumes |
Considering it will impact the search syntax, better first to all agree to what we want before making any changes. You can make changes (once it's agreed upon, otherwise it could be work for nothing, which isn't great) in new commits, it's fine. |
I disagree. Shipping an MVP that only works with one crate sounds fine, as long as things that work now continue to work in the future (gratuitous breakage is bad, but rustdoc search isn't bound by the extremely strict guarantees of the compiler). |
self-review: the type declarations in |
☔ The latest upstream changes (presumably #127589) made this pull request unmergeable. Please resolve the merge conflicts. |
0f37ddd
to
2718bf1
Compare
crate alternative to rust-lang#129769
2718bf1
to
91f184c
Compare
This comment has been minimized.
This comment has been minimized.
79e5b85
to
062cb82
Compare
Two UI bugs from trying a demo (testing on Chrome / Linux):
Overall the concept is good so I'm replying affirmatively to the poll. |
A syntax problem:
|
are you sure that's not existing behavior? I can't come up with a query to reproduce this. |
Honestly I don't know if this is easily fixable, even the ability to not have a comma in the first case is a bit of a hack. |
062cb82
to
2f3708a
Compare
I think that could be fixed by tweaking rust/src/librustdoc/html/static/js/search.js Lines 197 to 217 in 2f3708a
If it were tweaked to work more like |
@notriddle I tried adjusting personally, adding a bunch of fragile special cases just to syntactically overload I think we should just document that not requiring a comma when |
alternative to #129769
fixes #129537
limitations: currently, the crate filter has to be followed by a comma, so it'scrate:std, vec
.r? @notriddle