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

[rustdoc] Various issues with search tabs #45608

Closed
Seeker14491 opened this issue Oct 29, 2017 · 6 comments
Closed

[rustdoc] Various issues with search tabs #45608

Seeker14491 opened this issue Oct 29, 2017 · 6 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Seeker14491
Copy link
Contributor

Seeker14491 commented Oct 29, 2017

I've come across several issues related to the search tabs:

  • While on the search results screen, if you click on the "As parameters" or "As return value" tabs, then type in a query, the results shown are from the "Types/modules" tab.
  • The "As parameters" and "As return value" tabs only show results that have the query string in its name or path. Even then it's missing results. For example, std::thread::current has signature pub fn current() -> Thread, yet doesn't show up in the "As return value" tab when searching for "Thread".
  • When searching, functions whose name is the same as its return type are not shown on the "Types/modules" tab. (details in my second post)
  • I think the first tab shouldn't be labeled "Types/modules", as it also shows functions and macros. (moved to separate issue [rustdoc] Improve "Types/modules" label on the search results page #45787)

Link to the recent pull request implementing the search tabs

cc @GuillaumeGomez

@Seeker14491
Copy link
Contributor Author

This is the original issue I was going to post about.

When searching, functions whose name is the same as its return type are not shown. For example, the zip method of the iterator trait returns a struct called Zip. When you search for "zip" in the search bar, the zip function is absent from the default "Types/modules" tab of the results:
tmp1

It only appears in the "As return value" tab:
tmp2

I think the correct behavior should be the function appearing in both places.

I had a look at the source, and I believe the problem is here:

if (results['others'].length < maxResults && ((query.search && obj.name.indexOf(query.search)) || added === false))
{
    results['others'].push(obj);
}

Adding != -1 so the code looks like this fixes the issue:

if (results['others'].length < maxResults && ((query.search && obj.name.indexOf(query.search) != -1) || added === false))
{
    results['others'].push(obj);
}

I don't understand the code very well though.

@GuillaumeGomez
Copy link
Member

Oh nice, thanks for the feedback! I'll fix it today.

@TimNN TimNN added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Oct 31, 2017
@Seeker14491
Copy link
Contributor Author

Great work! The last point hasn't been addressed though. I think something like "In name" would be a better label. Thoughts?

@GuillaumeGomez
Copy link
Member

No clue... Might be worth opening a new issue so we can discuss about it.

@Seeker14491
Copy link
Contributor Author

Ok, opened #45787.

@GuillaumeGomez
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants