Skip to content
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

Merged
merged 6 commits into from Nov 13, 2017

Conversation

Projects
None yet
7 participants
@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Oct 31, 2017

This is what I was talking about @QuietMisdreavus. Now we have generics.

Waiting for #45617 to get merged.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 31, 2017

r? @QuietMisdreavus

(rust_highfive has picked a reviewer for you, use r? to override)

@GuillaumeGomez GuillaumeGomez referenced this pull request Nov 1, 2017

Merged

Search fixes #45617

@GuillaumeGomez GuillaumeGomez force-pushed the GuillaumeGomez:rustdoc-type-search-generic branch 3 times, most recently from fc2fb75 to 6f88227 Nov 1, 2017

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Nov 2, 2017

It's now fully functional. You can look for type as generic parameters and look for types such as "Result". A little screenshot of the last commit:

screen shot 2017-11-02 at 01 02 13

@GuillaumeGomez GuillaumeGomez changed the title [WIP] Only search over generic types in docs Only search over generic types in docs Nov 3, 2017

@GuillaumeGomez GuillaumeGomez changed the title Only search over generic types in docs Search over generic types in docs Nov 3, 2017

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Nov 3, 2017

Shouldn't some of these be in the "As return value" instead?

image

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:

image

For public perusal, i have a rendering of the current PR here.

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Nov 6, 2017

Now that #45617 is merged, can you rebase on top of it to factor out the commits that were taken from there?

return b;
}

function nbElements(obj) {

This comment has been minimized.

@projektir

projektir Nov 7, 2017

Contributor

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;

This comment has been minimized.

@projektir

projektir Nov 7, 2017

Contributor

I feel that this would be better off on the same line.

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Nov 7, 2017

Author Member

I agree, only issue: line > 100 columns. :)

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) {

This comment has been minimized.

@projektir

projektir Nov 7, 2017

Contributor

The check is literalSearch === true in other parts of the code.


if (obj && obj.type && obj.type.output) {
var tmp = checkType(obj.type.output, val, literalSearch);
if (literalSearch && tmp === true) {

This comment has been minimized.

@projektir

projektir Nov 7, 2017

Contributor

Same here.

@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented Nov 11, 2017

Ping from triage — @GuillaumeGomez will you be able to address some of the feedback you've received?

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Nov 11, 2017

I'll be able to address all of them.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 11, 2017

☔️ The latest upstream changes (presumably #45932) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez GuillaumeGomez force-pushed the GuillaumeGomez:rustdoc-type-search-generic branch from 597a82f to 942a4e9 Nov 11, 2017

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Nov 12, 2017

Updated.

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Nov 12, 2017

This still seems to have a problem of taking all the items that should be in "As parameters" and putting them into "Types/modules" instead.

Your PR:

image

image

Current nightly:

image

image

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Nov 12, 2017

Hum, still not good then... Let's see what's happening.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Nov 12, 2017

Ok, the mystery has been solved: I forgot to add the results into the tab. We're good now. :)

@QuietMisdreavus
Copy link
Member

QuietMisdreavus left a comment

Home stretch! With that last change, this totally works. Just one last nit and i'll be ready to call it good.

// FIXME: add all from clean::Type.
_ => None
}
}

fn get_generics(clean_type: &clean::Type) -> Option<Vec<String>> {
match *clean_type {
clean::ResolvedPath { ref path, .. } => {

This comment has been minimized.

@QuietMisdreavus

QuietMisdreavus Nov 12, 2017

Member

Can't this just reuse Type::generics rather than copying it out? That way, if other Types support generics, both this and the "document impls when the type appears in the traits generics" benefit.

@GuillaumeGomez GuillaumeGomez force-pushed the GuillaumeGomez:rustdoc-type-search-generic branch from 2246728 to 0e4c829 Nov 12, 2017

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Nov 12, 2017

Excellent! r=me pending travis.

Thanks so much for doing this! This makes the extended search tabs much nicer.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Nov 12, 2017

@bors: r=QuietMisdreavus

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 12, 2017

📌 Commit 0e4c829 has been approved by QuietMisdreavus

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 13, 2017

⌛️ Testing commit 0e4c829 with merge c8c1424...

bors added a commit that referenced this pull request Nov 13, 2017

Auto merge of #45673 - GuillaumeGomez:rustdoc-type-search-generic, r=…
…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.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 13, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: QuietMisdreavus
Pushing c8c1424 to master...

@bors bors merged commit 0e4c829 into rust-lang:master Nov 13, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@GuillaumeGomez GuillaumeGomez deleted the GuillaumeGomez:rustdoc-type-search-generic branch Nov 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.