-
Notifications
You must be signed in to change notification settings - Fork 198
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 lines labels to /crate/**/source/
#2551
Comments
I would be totally fine with having this feature and definitely see a use-case. I'm happy to review any PR adding this. the interesting files are: |
I'll look into this :D @rustbot claim |
there is a current big PR (#2292) that will change template rendering, not sure if you want to wait with your changes until it lands, or base your work ontop of it. |
In that case, I'll wait a bit. Thank you for the early notice :D |
I've made some decent progress. My next step is now to highlight the line numbers. I found the implementation of rustdoc which seems to work well. Can I copy and adapt it, as long as I add a comment mentioning where it comes from? I'm asking regarding the license etc. |
IANAL, but IMO you can just copy & adapt the code, even without attribution. @GuillaumeGomez what do you think? ( also about the piece of code ) |
Yes it's completely fine. Just need to be careful that the line height of the line number is aligned to the code line. |
…exendoo Lintcheck: Add URL to lint emission place in diff This PR adds links to the emission code in our lintcheck CI. When reviewing changes, I would like to be able to see the bigger context, which isn't always included in the lint message. This PR adds a nice link to the lintcheck diff that allows for simple investigation of the code in question. At first, I wanted to simply use the doc.rs links and call it a day, but then I figured out that some crates might have their source files remapped. Cargo was the crate that made me notice this. As a response, I made the link configurable. (See rust-lang/docs.rs#2551 for a detailed explanation and possible solution to remove this workaround in the future.) It's probably easiest to review the individual commits. The last one is just a dummy to showcase the change. [:framed_picture: rendered :framed_picture:](https://github.com/rust-lang/rust-clippy/actions/runs/9960834924?pr=13104) --- r? `@Alexendoo` changelog: none --- That's it, I hope that everyone who's reading this has a beautiful day :D
While generating some links, I noticed that source files under
https://docs.rs/crate/{crate}/{version}/source/src/{file}
don't support line labels. This is opposed to the sources underhttps://docs.rs/{crate}/{version}/src/{krate}/{file}.html#{line}
that do.Usually, I'd just use the second link with line label support for everything. However, rustdoc can sometimes remap paths, for example if a path is set in
Cargo.toml
. This means that the second link doesn't always work. At the end of the issue, I'll give a detailed example of this.For my use case, the best solution would be to add line numbers and line labels to the sources under
crate/{crate}/{version}/source/
.I'd be happy to give the implementation a shot, if this is something that would be accepted and I get some hints where to start 🗡️
Specific example:
We run Clippy in our CI and collect lint emissions. These diagnostics have paths as seen by rustc. It would, for example, look like this:
./src/lib.rs:15
. I now want to take these file names and link to docs.rs to help us investigate the lint emissions. For most crates, the link is simply constructed like this:https://docs.rs/{krate}/{version}/src/{krate}/{file}.html#{line}
And this works for most crates, expect crates that remap their path in
Cargo.toml
, like this (Taken from rust-lang/cargo):The lint emission then has the path
./src/cargo/lib.rs
but the documentation generated by rustdoc removes thecargo
from the path. So using the previous link template generates:This doesn't work due to the
cargo/cargo
. The correct link with the remapped path is:This remapping only happens for rustdoc and not the source files under
crate/
so if those would support line labels, it would be a simple way to always use the same link template.The text was updated successfully, but these errors were encountered: