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: Primitive data type methods like min/max/clamp are not discoverable #61190

Open
dwbuiten opened this issue May 25, 2019 · 14 comments
Open
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@dwbuiten
Copy link

Currently, searching the rust stdlib docs for, as an example, 'i32 min', will not find any info at all, and the the i32 page (https://doc.rust-lang.org/std/primitive.i32.html) is not searchable with standard CTRL-F in some browsers like Firefox, since min/max/clamp are hidden under the by-default-collapsed section on Ord. This lack of searchability/discoverability extends to Google results.

I'm not sure what the bets method to remedy this is, but fixing the on-site search to know about these is probably a good start.

@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 25, 2019
@the8472
Copy link
Member

the8472 commented May 25, 2019

There's basically a difference between searching for a method and looking whether certain trait implementations exist for a type.

Maybe implemented traits and trait methods should be listed separately. Then one could have a list of all available methods (annotated with trait bounds and which trait they come from) and a list of implemented traits.

@dwbuiten
Copy link
Author

I can't speak for the approach or implementation, but the outcome you describe sounds desireable, to me, anyway.

@czipperz
Copy link
Contributor

I might add that I have been running into this issue a lot recently. I think at some point recently the docs for traits were automatically collapsed.

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented May 27, 2019

The rustdoc search is very basic. If you're looking for something with whitespaces in the request, it'll very likely not work. In your case, maybe try "i32::min"?

Otherwise, I don't really see how to fix this issue... :-/

@dwbuiten
Copy link
Author

Having to type in something so exact (and like I said, this affects Google results too!) is not very useful for discoverability. This especially effects people who are new to Rust, like myself.

@GuillaumeGomez
Copy link
Member

I understand your problem, I'm just telling you that I don't know how to solve it. We can't embedded a powerful parser and certainly not an NLP one...

@the8472
Copy link
Member

the8472 commented May 27, 2019

this affects Google results too!

I think that particular issue could be fixed by using HTML's <details>/<summary>, which will hide the collapsed content from the user but not from the search engines.

@lu-zero
Copy link
Contributor

lu-zero commented Jun 18, 2019

If we want to go on the overkill side we could have tiny engines like sonic or tinysearch.

But to make the problem less impacting in the short term it would be enough to map the search query on the existing index to the query and an additional one with spaces replaced with ::.

@GuillaumeGomez
Copy link
Member

If it's not fully embeddable in the front, then it's very likely we won't give it a look. We want to keep rustdoc able to work locally without an internet connection.

@lu-zero
Copy link
Contributor

lu-zero commented Jun 23, 2019

both can be compiled to wasm, but it really boils down to change how the query behaves in front of spaces between words.

@GuillaumeGomez
Copy link
Member

The search engine is in src/librustdoc/html/static/main.js if you want to take a look. Any idea is very welcome. :)

@czipperz
Copy link
Contributor

@lu-zero
Copy link
Contributor

lu-zero commented Jun 24, 2019

javascript is not my favourite language and that file isn't exactly short.

If you could point me to where the search term are managed I can try to add the 5 ugly lines to generate additional items from the initial search string, but I'm quite sure that who wrote that would be much quicker than me in doing that.

@pickfire
Copy link
Contributor

pickfire commented Jun 11, 2020

Why not tinysearch? I bet it could speed up the search timings, right now I still feel some latency from rustdoc searches. Hopefully the speedup is as much as switching from JS parsing to JSON parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

7 participants