Skip to content

Deny broken intra-doc links in linkchecker - #77971

Merged
bors merged 2 commits into
rust-lang:masterfrom
jyn514:broken-intra-doc-links
Oct 16, 2020
Merged

Deny broken intra-doc links in linkchecker#77971
bors merged 2 commits into
rust-lang:masterfrom
jyn514:broken-intra-doc-links

Conversation

@jyn514

@jyn514jyn514 commented Oct 15, 2020

Copy link
Copy Markdown
Member

Since rustdoc isn't warning about these links, check for them manually.

This also fixes the broken links that popped up from the lint.

@jyn514jyn514 added A-testsuite Area: The testsuite used to check the correctness of rustc A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 15, 2020
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2020
@jyn514jyn514 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2020
@jyn514

Copy link
Copy Markdown
MemberAuthor

This caught quite a lot of broken links:

Details
std/option/enum.Option.html:216: broken intra-doc link - [<code>Some(t)</code>]
std/iter/trait.DoubleEndedIterator.html:87: broken intra-doc link - [<code>Ok(())</code>]
std/iter/trait.DoubleEndedIterator.html:88: broken intra-doc link - [<code>Err(k)</code>]
std/iter/trait.DoubleEndedIterator.html:91: broken intra-doc link - [<code>Ok(())</code>]
std/ffi/struct.CStr.html:205: broken intra-doc link - [<code>&amp;str</code>]
std/ffi/struct.CStr.html:206: broken intra-doc link - [<code>&amp;str</code>]
std/ffi/struct.CString.html:355: broken intra-doc link - [<code>&amp;str</code>]
std/ffi/struct.CString.html:356: broken intra-doc link - [<code>&amp;str</code>]
std/ops/struct.RangeInclusive.html:253: broken intra-doc link - [<code>begin</code>, <code>end</code>]
std/slice/trait.SliceIndex.html:76: broken intra-doc link - [<code>begin</code>, <code>end</code>]
std/alloc/trait.AllocRef.html:68: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
std/alloc/trait.AllocRef.html:71: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
std/alloc/trait.AllocRef.html:96: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
std/alloc/trait.AllocRef.html:105: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
std/alloc/trait.AllocRef.html:148: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
std/alloc/trait.AllocRef.html:157: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
std/convert/trait.AsRef.html:30: broken intra-doc link - [<code>&amp;str</code>]
std/convert/trait.AsRef.html:31: broken intra-doc link - [<code>&amp;str</code>]
unstable-book/print.html:4209: broken intra-doc link - [<code>Default::default()</code>]
unstable-book/library-features/default-free-fn.html:170: broken intra-doc link - [<code>Default::default()</code>]
reference/print.html:298: broken intra-doc link - [<code>b</code> <code>B</code>]
reference/print.html:299: broken intra-doc link - [<code>a</code>-<code>z</code>]
reference/print.html:300: broken intra-doc link - [<code>b</code> <code>B</code>]
reference/print.html:440: broken intra-doc link - [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code>] [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code> <code>0</code>-<code>9</code> <code>_</code>]
reference/print.html:441: broken intra-doc link - [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code> <code>0</code>-<code>9</code> <code>_</code>]
reference/print.html:467: broken intra-doc link - [<code>/</code> <code>!</code>]
reference/print.html:470: broken intra-doc link - [<code>*</code> <code>!</code>]
reference/print.html:885: broken intra-doc link - [<code>0</code>-<code>1</code>]
reference/print.html:886: broken intra-doc link - [<code>0</code>-<code>7</code>]
reference/print.html:887: broken intra-doc link - [<code>0</code>-<code>9</code>]
reference/print.html:888: broken intra-doc link - [<code>0</code>-<code>9</code> <code>a</code>-<code>f</code> <code>A</code>-<code>F</code>]
reference/comments.html:172: broken intra-doc link - [<code>/</code> <code>!</code>]
reference/comments.html:175: broken intra-doc link - [<code>*</code> <code>!</code>]
reference/identifiers.html:172: broken intra-doc link - [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code>] [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code> <code>0</code>-<code>9</code> <code>_</code>]
reference/identifiers.html:173: broken intra-doc link - [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code> <code>0</code>-<code>9</code> <code>_</code>]
reference/tokens.html:459: broken intra-doc link - [<code>0</code>-<code>1</code>]
reference/tokens.html:460: broken intra-doc link - [<code>0</code>-<code>7</code>]
reference/tokens.html:461: broken intra-doc link - [<code>0</code>-<code>9</code>]
reference/tokens.html:462: broken intra-doc link - [<code>0</code>-<code>9</code> <code>a</code>-<code>f</code> <code>A</code>-<code>F</code>]
reference/notation.html:181: broken intra-doc link - [<code>b</code> <code>B</code>]
reference/notation.html:182: broken intra-doc link - [<code>a</code>-<code>z</code>]
reference/notation.html:183: broken intra-doc link - [<code>b</code> <code>B</code>]
embedded-book/print.html:4208: broken intra-doc link - [<code>std::process::Command</code>]
embedded-book/interoperability/c-with-rust.html:233: broken intra-doc link - [<code>std::process::Command</code>]
alloc/slice/trait.SliceIndex.html:34: broken intra-doc link - [<code>begin</code>, <code>end</code>]
alloc/alloc/trait.AllocRef.html:68: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
alloc/alloc/trait.AllocRef.html:71: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
alloc/alloc/trait.AllocRef.html:96: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
alloc/alloc/trait.AllocRef.html:105: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
alloc/alloc/trait.AllocRef.html:148: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
alloc/alloc/trait.AllocRef.html:157: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
error-index.html:10959: broken intra-doc link - [<code>llvm_asm</code>]
error-index.html:10969: broken intra-doc link - [<code>llvm_asm</code>]
error-index.html:10982: broken intra-doc link - [<code>llvm_asm</code>]
error-index.html:10995: broken intra-doc link - [<code>llvm_asm</code>]
error-index.html:11008: broken intra-doc link - [<code>llvm_asm</code>]
core/option/enum.Option.html:216: broken intra-doc link - [<code>Some(t)</code>]
core/iter/trait.DoubleEndedIterator.html:87: broken intra-doc link - [<code>Ok(())</code>]
core/iter/trait.DoubleEndedIterator.html:88: broken intra-doc link - [<code>Err(k)</code>]
core/iter/trait.DoubleEndedIterator.html:91: broken intra-doc link - [<code>Ok(())</code>]
core/ops/struct.RangeInclusive.html:250: broken intra-doc link - [<code>begin</code>, <code>end</code>]
core/slice/trait.SliceIndex.html:76: broken intra-doc link - [<code>begin</code>, <code>end</code>]
core/alloc/trait.AllocRef.html:68: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
core/alloc/trait.AllocRef.html:71: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
core/alloc/trait.AllocRef.html:96: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
core/alloc/trait.AllocRef.html:105: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
core/alloc/trait.AllocRef.html:148: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
core/alloc/trait.AllocRef.html:157: broken intra-doc link - [<code>NonNull&lt;[u8]&gt;</code>]
core/convert/trait.AsRef.html:30: broken intra-doc link - [<code>&amp;str</code>]
core/convert/trait.AsRef.html:31: broken intra-doc link - [<code>&amp;str</code>]
cargo/print.html:3528: broken intra-doc link - [<code>cargo rustdoc</code>]
cargo/reference/environment-variables.html:194: broken intra-doc link - [<code>cargo rustdoc</code>]
thread 'main' panicked at 'found some broken links', src/tools/linkchecker/main.rs:73:9

@jyn514

Copy link
Copy Markdown
MemberAuthor

The ones in the reference seem to be intentional, they're ~EBNF and marking literals as code blocks. I'll ignore them in the linkchecker.

@jyn514
jyn514force-pushed the broken-intra-doc-links branch from e3147d1 to 110fd0aCompareOctober 15, 2020 14:20
bors added a commit to rust-lang/cargo that referenced this pull request Oct 15, 2020
@jyn514
jyn514force-pushed the broken-intra-doc-links branch from 110fd0a to dd161d9CompareOctober 15, 2020 14:57
@jyn514jyn514 changed the title [WIP] deny broken intra-doc links in linkcheckerDeny broken intra-doc links in linkcheckerOct 15, 2020
@jyn514

jyn514 commented Oct 15, 2020

Copy link
Copy Markdown
MemberAuthor

This is now blocked on a cargo update, rust-embedded/book#271 merged, and an embedded-book update. Otherwise it's ready for review though.

borsBot added a commit to rust-embedded/book that referenced this pull request Oct 15, 2020
271: Fix broken link to std::process::Command r=therealprof a=jyn514
Intra-doc links do not yet work in markdown files; see rust-lang/rust#77974.
Part of rust-lang/rust#77971.
Co-authored-by: Joshua Nelson <jyn514@gmail.com>
Comment threadcompiler/rustc_error_codes/src/error_codes/E0660.md Outdated
Comment threadcompiler/rustc_error_codes/src/error_codes/E0661.md Outdated
Comment threadcompiler/rustc_error_codes/src/error_codes/E0662.md Outdated
Comment threadsrc/tools/linkchecker/main.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you want to run this check on html?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there's no way for the linkchecker to tell if a link will be resolved by rustdoc or not. It has to look at the HTML to see whether the markdown was transformed into a link or left as-is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds really risky. :-/

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean by risky. What would be a better way? This inherently wants to look at the generated HTML, not the original, because you could have concat!( and #[doc = ...] and all sorts of other things that linkchecker doesn't and shouldn't know about.

Since rustdoc isn't warning about these links, check for them manually.
@jyn514
jyn514force-pushed the broken-intra-doc-links branch from dd161d9 to b221819CompareOctober 16, 2020 00:30
@jyn514

Copy link
Copy Markdown
MemberAuthor

Ok, this should be ready to go now. I updated two submodules that had broken links (the commit message has a /compare url).

@jyn514jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2020
@GuillaumeGomez

Copy link
Copy Markdown
Member

This looks good to me. Let's wait for @Mark-Simulacrum's review too.

@Mark-Simulacrum

Copy link
Copy Markdown
Member

I guess this seems fine, r=me.

It does feel like the sort of thing that would be better to fix in rustdoc, but I'm sure you're aware of that :)

@Mark-Simulacrum

Copy link
Copy Markdown
Member

Oh, one note I wanted to make -- it look like this is now fixing links, could you update PR description?

@jyn514

Copy link
Copy Markdown
MemberAuthor

Updated!

It does feel like the sort of thing that would be better to fix in rustdoc, but I'm sure you're aware of that :)

Yeah ... I'd like to have #77200 and #77199 but the rest of the rustdoc team disagrees with me (#77276 (comment), various conversations on discord). In the meantime this should catch most of the broken links.

This is still a good change even if those issues were fixed though IMO - it protects against bugs in rustdoc (and hopefully makes them easier to find).

@jyn514

Copy link
Copy Markdown
MemberAuthor

@bors r=@Mark-Simulacrum

@bors

bors commented Oct 16, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit b221819 has been approved by mark-simulacrum

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 16, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Oct 16, 2020
…rk-simulacrum
Deny broken intra-doc links in linkchecker
Since rustdoc isn't warning about these links, check for them manually.
This also fixes the broken links that popped up from the lint.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 16, 2020
…rk-simulacrum
Deny broken intra-doc links in linkchecker
Since rustdoc isn't warning about these links, check for them manually.
This also fixes the broken links that popped up from the lint.
@JohnTitorJohnTitor mentioned this pull request Oct 16, 2020
@JohnTitorJohnTitor mentioned this pull request Oct 16, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2020
Rollup of 10 pull requests
Successful merges:
- rust-lang#75209 (Suggest imports of unresolved macros)
- rust-lang#77547 (stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union')
- rust-lang#77827 (Don't link to nightly primitives on stable channel)
- rust-lang#77855 (resolve: further improvements to "try using the enum's variant" diagnostic)
- rust-lang#77900 (Use fdatasync for File::sync_data on more OSes)
- rust-lang#77925 (Suggest minimal subset features in `incomplete_features` lint)
- rust-lang#77971 (Deny broken intra-doc links in linkchecker)
- rust-lang#77991 (Bump backtrace-rs)
- rust-lang#77992 (instrument-coverage: try our best to not ICE)
- rust-lang#78013 (Fix sidebar scroll on mobile devices)
Failed merges:
r? `@ghost`
@bors
bors merged commit 050eb4d into rust-lang:masterOct 16, 2020
@rustbotrustbot added this to the 1.49.0 milestone Oct 16, 2020
@ollie27ollie27 mentioned this pull request Oct 17, 2020
@jyn514
jyn514 deleted the broken-intra-doc-links branch November 7, 2020 18:19
@jyn514jyn514 mentioned this pull request Nov 13, 2020
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 6, 2023
linkchecker: Remove unneeded FIXME about intra-doc links
It was added by rust-lang#77971 but the adder [proposed](rust-lang#77971 (comment)) that the added code is a good fallback to have in case rustdoc gets buggy, and I agree. So remove the FIXME.
This PR is part of rust-lang#44366 which is E-help-wanted.
r? `@jyn514` since you added the FIXME
`@rustbot` label T-dev-tools
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-testsuiteArea: The testsuite used to check the correctness of rustcS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@jyn514@rust-highfive@GuillaumeGomez@Mark-Simulacrum@bors@rustbot