-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Resolve intra-doc-links on Self type implicitly #59039
Comments
Are you saying |
I'd rather stick to the language rules if possible than create a subtly different dialect working only in rustdoc links. |
Pick the function first, if it exists, and if not look for the method. You can always disambiguate with full paths. I don't see how this is a problem, intra doc links already does a bunch of fallbacky things, this would be another.
I was going through intra doc failures in servo's deps (debugging a rustdoc regression and in the process noticing warnings) and it's common for people to do this and expect it to work already. It's a pretty common use case; method and type docs cross link to other methods all the time. We should support it. I don't see why intra doc links (which already have a bunch of special syntax) should stick to the language rules. |
(This may need an RFC, though, but it's worth getting it on file somewhere) |
I think it could create confusion as to what the language rules are for some users. Such confusion will cease when users actually try |
I disagree that intra-doc-links are fundamentally viewed as paths in the same way. The main use case is to name types and methods (so, rarely full paths, usually This is the same kind of magic as doctests, IMO: nobody sees doctests and assumes that there's a way to write Rust programs without a And yeah, like I said, people are trying this already! (I'll have to look for the crates again) |
Actually I think the best way to look at intra doc links is that if you're doing |
@Manishearth You make a good case overall. I still think there's a bit of a risk for some users, but it may be small enough to not matter in the grand scheme. An RFC sounds like a good place to flesh it all out. |
Sounds good. Might open one, depending on what the docs team feels about this feature overall. |
Note to anyone that might be confused, the original example of |
This comment has been minimized.
This comment has been minimized.
I don't know if |
Copying over what I said in a dupe issue since despite looking over every issue tagged intra-doc-links I missed this one: I think if there's any ambiguity, there should be a lint to request you state |
A pattern of documentation I frequently find myself writing is
This has fewer risks of ambiguity, and fits with the language rules -- spoken language has more context than a programming language, and in the docs of something that can have members, self would be a logical subject. As a whole, is this issue still in the state where the next step is an RFC to flesh out precise rules? |
|
@jyn514 iirc that's not the case: it's a parser controlled by us that does this, but it has a quick-reject heuristic that uses |
I think this is the code that parses links, looks like it doesn't treat rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 879 to 891 in f79fae3
|
With intra-doc-links, the following works:
but this does not:
For structs and impls we should try resolving things against
Self
anywayThe text was updated successfully, but these errors were encountered: