-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Generate links to definition in rustdoc source code pages #84176
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
Conversation
This comment has been minimized.
This comment has been minimized.
b4a575a to
7a09118
Compare
This comment has been minimized.
This comment has been minimized.
7a09118 to
f0cd8e5
Compare
|
I added a little improvement: when a source code link is hovered, the link is underlined (like what we have in the "path" of the items at the top of the documentation page). |
|
For the span panics, one theory to explain it could be because we leave the "compiler scope". Meaning that it's a potential bug that went uncovered for quite a long time... Thanks to @estebank for this! I'll move the source code pages generation into that scope and check if we still have the panic or not. |
|
I still feel like this is a major expansion of scope and would prefer it goes through an RFC first (https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/extend.20source.20code.20viewer). @Manishearth what do you think? |
|
I thought we agreed on having a disabled by default first implementation to be able to get feedback and potential new suggestions on the feature in order to then open an RFC, but maybe I completely misunderstood... In this case, an RFC would mean at least months before being able to get any feedback based on an experimental first implementation. It wouldn't be the first time that a feature gets implemented and remains disabled by default to get feedback before opening an RFC to stabilize it and enable it by default. |
Could you make it always underlined? That matches what haddock does and makes it easier to see what is clickable and what is not. And maybe also highlight the background when hovering. This is what haddock does: IMHO the contrast is a bit low though. |
|
@bjorn3 I'd rather not (personal opinion: it would attract the eye and make it more difficult to read the source code because of the distractions, up to debate), or at least not for the moment. The goal of this PR (once it's merged) is to set a base on which people can experiment and try things and then debate on what we want in the end (through a RFC). |
This comment has been minimized.
This comment has been minimized.
c4a8413 to
b06f170
Compare
This comment has been minimized.
This comment has been minimized.
b06f170 to
3de82ea
Compare
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.
I'd like to see a lot more documentation. My main worry continues to be maintenance, this is smaller than I thought but I want to make sure that the team is well equipped to maintain it. Good documentation is a part of that
From the feature's side, should item definitions link to their own docs so that you can always jump back to the docs?
This comment has been minimized.
This comment has been minimized.
3de82ea to
6265286
Compare
|
I keep failing my pushes for some reasons... All hail |
This is an excellent point. I'll add documentation on all new functions/types I created.
Funny, I was wondering about that too. I have some ideas about it. For example adding a |
This comment has been minimized.
This comment has been minimized.
4ab2b5e to
ba11dc7
Compare
|
@bors: r=jyn514 |
|
📌 Commit ba11dc7 has been approved by |
|
☀️ Test successful - checks-actions |


Description
This PR adds an option (disabled by default) to add links in the source code page on ident. So for for example:
In the example (mostly in the
xfunction),other_module::Trait,Foo,other_module::Whatever,barandsome_methodare now links (andother_moduleat the top too).In case there is a type coming from another crate, it'll link to its documentation page and not its definition (but you can then click on
[src]so I guess it's fine).Another important detail: I voluntarily didn't add links for primitive types. I think we can discuss about adding links on them or not in a later PR (adding the support for them would require only a few lines).
Here is a video summing up everything I wrote above:
Peek.2021-04-13.23-15.mp4
Performance impact
So, on my computer, the performance remains more or less the same (which is quite surprising but that's a nice surprise). Here are the numbers:
Without the option:
With source to definition links generation (I enabled by default the option):
So no real change here (again, I'm very surprised by this fact).
For the size of the generated source files (only taking into account the
srcfolder here since it's the only one impacted) by runningdu -shc .(when I am in the source folder).Without the option: 11.939 MB
With the option: 12.611 MB
So not a big change here either. In all those docs, I ran
grep -nR '<a class=' . | wc -land got 43917. So there are quite a lot of links added. :)cc @rust-lang/rustdoc
r? @jyn514