-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 lint for broken doc links #13696
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Jarcho (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
8d859c9
to
6ff53c7
Compare
Just noticed there are tests failing due to a false positive like this:
This will be considered a broken link although actually it isn't. I guess in order to fix it I won't be able to check |
I will try to use similar approach used on https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/tabs_in_doc_comments.rs |
fc34f5d
to
640f282
Compare
640f282
to
8deb383
Compare
☔ The latest upstream changes (presumably 8298da7) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Sorry for the long wait. Left a couple of specific comments.
One thing you'll need to do is take the text input from the markdown parser. Currently you'll be linting inside code and html sections. Doc attribute can also contain multiple lines.
@Jarcho thanks for taking the time to review this. I applied two of your code improvement suggestions. I am a bit confused though about these others comments:
Do you mean this lint should run on this parser's output instead of running before that step, which is done against the rust AST attributes? I tried doing that as the first approach, but the
It is being applied only for
This current logic is checking for broken links across multiple lines, so I am confused what you mean on this one, as it is already checking for multiple lines. |
@rustbot review |
Yes. And markdown contain code and html sections. Neither of which will try to parse links.
Right now you're assuming that each attribute contains a single line. This is normally true, but isn't guaranteed. |
@Jarcho So, to make sure I got it right:
Are you saying About this other one:
Would attributes with multiple lines be represented with |
I don't see why that would stop this from working. You can use the span given to the callback to know where to start parsing the input string for the link's destination.
rustdoc joins all the doc attributes together with |
fixes #2179
changelog: [
doc_broken_link
]: Add pedantic lint to catch broken doc links that won't produce a link tag by rustdoc.