-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add support for "true"/"false" intra doc link #75101
Add support for "true"/"false" intra doc link #75101
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 |
How do we know these are the only primitive values that have keywords? I'm ok with this workaround but I want to be sure we didn't miss anything. |
Ok, there is a list of keywords at https://doc.rust-lang.org/std/index.html#keywords. Do we want to support all of those, like |
I think we should at least support |
|
CI failure:
|
It seems a bit odd to link to the bool type for these rather than https://doc.rust-lang.org/nightly/std/keyword.true.html and https://doc.rust-lang.org/nightly/std/keyword.false.html -- if we're going to autolink keywords, we should link to the keyword documentation, I think. |
Oh I see, we had two different things in mind. Then we could try to do this based on the doc aliases directly, don't you think? Or should we keep a list based on the official keywords and only link using those? The second solution would allow a much simpler fix. |
I think linking by doc-aliases would be the best approach - that would link to all keywords, right? The issue with special-casing keywords is that now we have to hard-code either stable or nightly; if we use resolve for it then it will always be the appropriate version. |
Ok, I'll update the PR with this change. |
match PRIMITIVES.iter().find(|(ty, _)| *ty == "bool") { | ||
Some((_, res)) => (*res, Some("bool".to_owned())), | ||
None => { | ||
resolution_failure(cx, &item, path_str, &dox, link_range); | ||
continue; | ||
} |
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.
Should this be always checking in a loop? Shouldn't we get bool
only once or make this static?
I think we should link to the keywords here. But I'm kinda skeptical of doing this at all, these are keywords and not paths. Seems ok for true and false but maybe not so much for other keywords. I also see a very low utility for it, and because they're not paths, I don't expect people to reach for them aside from the bool literals (which behave kinda like paths, at least) |
FWIW I'm ok with just not implementing this, this is definitely out of the scope of the original RFC. Up to @GuillaumeGomez if he wants to go through with the PR since he already wrote a lot of it. If we do implement it though, I think it would be nice to make it work for all keywords. |
Honestly I'm not sure it's worth it so let's just keep it simple. I'll update to link to the keyword pages though. |
I'm very against linking to all keywords, the only reason I'm somewhat okay with this one is because |
Yes we agree, only keywords for |
14a9aca
to
4d2a53f
Compare
Updated! |
No that was a response to @jyn514 who wanted us to do all keywords if we do true/false. |
4d2a53f
to
66d998f
Compare
Oh I see, well, we can talk about it at a later time if enough people are interested. But currently, not very convinced. |
@bors r+ |
@bors r- two team members are against it at this point. Maybe we should hold off unless there's strong motivation? |
I don't have strong feelings here so we can close it if everyone agrees? |
Sounds good to me. |
This came up again in #75567, which has 38 different links to |
Well, if enough people are interested, please reopen then. 😆 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
What would they link to? I think linking to the |
I agree with Ollie here |
Linking to |
|
If we're just linking to bool, the code can be simplified quite a bit, @GuillaumeGomez just needs to add an alias next to
Well, they can't really because |
Oh that's nice if it doesn't ask for a lot of code. Yeah, linking to bool is better I think. |
Opened #75652 which links @GuillaumeGomez do you mind if I close this PR (again :P)? |
Too late, I already did! :p |
Resolve true and false as booleans Successor to rust-lang#75101. r? @Manishearth cc @rust-lang/rustdoc
Resolve true and false as booleans Successor to rust-lang#75101. r? @Manishearth cc @rust-lang/rustdoc
Resolve true and false as booleans Successor to rust-lang#75101. r? @Manishearth cc @rust-lang/rustdoc
Part of #74515.
Explanations of what I did here: instead of checking more globally in primitive types, I think that only
true
andfalse
values should be transformed into a link tobool
. Others are either numbers or strings and I don't think we want to link all of them "generally". So in here, in casetrue
andfalse
didn't match anything (maybe a module was here, we don't know?), we then link them to thebool
type.r? @jyn514
cc @rust-lang/rustdoc