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

Clean up doc_alias feature #76705

Closed
GuillaumeGomez opened this issue Sep 14, 2020 · 15 comments · Fixed by #76811
Closed

Clean up doc_alias feature #76705

GuillaumeGomez opened this issue Sep 14, 2020 · 15 comments · Fixed by #76811
Assignees
Labels
A-doc-alias Area: `#[doc(alias)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@GuillaumeGomez
Copy link
Member

From this comment: #50146 (comment)

Still remaining the .replace().

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Sep 14, 2020
@GuillaumeGomez GuillaumeGomez self-assigned this Sep 14, 2020
@GuillaumeGomez
Copy link
Member Author

Actually, the " character has a meaning in the search (for "exact" search). But instead of just removing it, maybe we should instead emit an error when we encounter it. What do you think @ollie27 ?

@ollie27
Copy link
Member

ollie27 commented Sep 15, 2020

Actually, the " character has a meaning in the search (for "exact" search).

That doesn't work for #[doc(alias = "...")] though, maybe it should?

But instead of just removing it, maybe we should instead emit an error when we encounter it.

It would make sense to restrict allowed characters because even whitespace is allowed at the moment which seems questionable.

@Mark-Simulacrum
Copy link
Member

It sounds like we need to make sure this lands before we branch beta or so?

@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.47.0, 1.48.0 Sep 15, 2020
@GuillaumeGomez
Copy link
Member Author

Let's forbid ", whitespaces and tabs in the the doc alias then.

@Mark-Simulacrum
Copy link
Member

Can we avoid ad-hoc rules and say something like "must be a rust identifier"?

@GuillaumeGomez
Copy link
Member Author

Even better! Great suggestion @Mark-Simulacrum !

@GuillaumeGomez
Copy link
Member Author

Just thought about it, but it cannot be the case @Mark-Simulacrum : we allow things like "*" or "+" (for the traits for example), so it cannot be ident only. I'll stick to the listed characters above.

@Mark-Simulacrum
Copy link
Member

@GuillaumeGomez
Copy link
Member Author

Doc aliases can be something else than a rust identifier. For example, you can look for & or + in the std docs, and you'll see aliases results.

@Mark-Simulacrum
Copy link
Member

Ah, I see what you mean. Okay, then I agree that we need more than just Rust identifiers, and it might be reasonable to just allow as you suggest -- everything except whitespace and quotes. I'm a bit worried that'll hurt us in terms of how expansive it is but it's probably fine.

@GuillaumeGomez
Copy link
Member Author

I don't expect #[doc(alias = "..."")] attributes to be used widely, so we should be fine. ;)

@jyn514 jyn514 added the A-doc-alias Area: `#[doc(alias)]` label Sep 27, 2020
@bors bors closed this as completed in c7c2418 Oct 2, 2020
@lopopolo
Copy link
Contributor

lopopolo commented Oct 3, 2020

It would make sense to restrict allowed characters because even whitespace is allowed at the moment which seems questionable.

Is there more justification for removing whitespace support other than calling the characters questionable? If I have a struct or a function that implements an algorithm, I would like to alias the item to the plaintext name of the algorithm, for example Mersenne twister.

@GuillaumeGomez
Copy link
Member Author

I just had in mind "idents", so no whitespace in them. However I don't see any reason to not allow ' ' specfically. I'll send a PR tomorrow.

@lopopolo
Copy link
Contributor

lopopolo commented Oct 4, 2020

rustdoc only being ident-centric is something that I wish would be improved.

I wish that rustdoc search was for more than types and functions I already know the names of. I would hope that a search for "vector" would return Vec near the top instead of not at all.

@GuillaumeGomez
Copy link
Member Author

path-centric would be more accurate. ;)

JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 14, 2020
…, r=jyn514,ollie27

Allow ascii whitespace char for doc aliases

Fixes issue from rust-lang#76705 (comment)

cc @lopopolo @ollie27

r? @jyn514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doc-alias Area: `#[doc(alias)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants