-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Search over generic types in docs #45673
Search over generic types in docs #45673
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
fc2fb75
to
6f88227
Compare
Shouldn't some of these be in the "As return value" instead? I would expect the "As return value" tab to prioritize perfect matches of one of the type variables over ones that have no type variables but have a low lev score: For public perusal, i have a rendering of the current PR here. |
Now that #45617 is merged, can you rebase on top of it to factor out the commits that were taken from there? |
src/librustdoc/html/static/main.js
Outdated
return b; | ||
} | ||
|
||
function nbElements(obj) { |
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.
I think numElements
would be a better name for this.
if (obj.generics && | ||
obj.generics.length >= val.generics.length) { | ||
var elems = obj.generics.slice(0); | ||
for (var y = 0; |
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.
I feel that this would be better off on the same line.
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.
I agree, only issue: line > 100 columns. :)
src/librustdoc/html/static/main.js
Outdated
if (obj && obj.type && obj.type.inputs.length > 0) { | ||
for (var i = 0; i < obj.type.inputs.length; i++) { | ||
if (obj.type.inputs[i].name === val) { | ||
var tmp = checkType(obj.type.inputs[i], val, literalSearch); | ||
if (literalSearch && tmp === true) { |
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.
The check is literalSearch === true
in other parts of the code.
src/librustdoc/html/static/main.js
Outdated
|
||
if (obj && obj.type && obj.type.output) { | ||
var tmp = checkType(obj.type.output, val, literalSearch); | ||
if (literalSearch && tmp === true) { |
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.
Same here.
Ping from triage — @GuillaumeGomez will you be able to address some of the feedback you've received? |
I'll be able to address all of them. |
☔ The latest upstream changes (presumably #45932) made this pull request unmergeable. Please resolve the merge conflicts. |
597a82f
to
942a4e9
Compare
Updated. |
Hum, still not good then... Let's see what's happening. |
Ok, the mystery has been solved: I forgot to add the results into the tab. We're good now. :) |
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.
Home stretch! With that last change, this totally works. Just one last nit and i'll be ready to call it good.
src/librustdoc/html/render.rs
Outdated
// FIXME: add all from clean::Type. | ||
_ => None | ||
} | ||
} | ||
|
||
fn get_generics(clean_type: &clean::Type) -> Option<Vec<String>> { | ||
match *clean_type { | ||
clean::ResolvedPath { ref path, .. } => { |
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.
Can't this just reuse Type::generics rather than copying it out? That way, if other Type
s support generics, both this and the "document impls when the type appears in the traits generics" benefit.
2246728
to
0e4c829
Compare
Excellent! r=me pending travis. Thanks so much for doing this! This makes the extended search tabs much nicer. |
@bors: r=QuietMisdreavus |
📌 Commit 0e4c829 has been approved by |
…QuietMisdreavus Search over generic types in docs This is what I was talking about @QuietMisdreavus. Now we have generics. Waiting for #45617 to get merged.
☀️ Test successful - status-appveyor, status-travis |
This is what I was talking about @QuietMisdreavus. Now we have generics.
Waiting for #45617 to get merged.