Skip to content
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

Deny broken intra-doc links in linkchecker #77971

Merged
merged 2 commits into from
Oct 16, 2020

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Oct 15, 2020

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

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

@jyn514 jyn514 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
Collaborator

r? @Mark-Simulacrum

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

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

jyn514 commented Oct 15, 2020

This caught quite a lot of broken links:

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
Member Author

jyn514 commented Oct 15, 2020

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.

bors added a commit to rust-lang/cargo that referenced this pull request Oct 15, 2020
Fix broken link in reference docs

Found in rust-lang/rust#77971.
@jyn514 jyn514 changed the title [WIP] deny broken intra-doc links in linkchecker Deny broken intra-doc links in linkchecker Oct 15, 2020
@jyn514
Copy link
Member Author

jyn514 commented Oct 15, 2020

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.

bors bot 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 <[email protected]>
@@ -50,6 +53,44 @@ const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[
("alloc/collections/btree_set/struct.BTreeSet.html", &["#insert-and-complex-keys"]),
];

#[rustfmt::skip]
const INTRA_DOC_LINK_EXCEPTIONS: &[(&str, &[&str])] = &[
Copy link
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
Member Author

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
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
Member Author

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
Copy link
Member Author

jyn514 commented Oct 16, 2020

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

@jyn514 jyn514 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
Member

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

@Mark-Simulacrum
Copy link
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
Member

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

@jyn514
Copy link
Member Author

jyn514 commented Oct 16, 2020

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
Member Author

jyn514 commented Oct 16, 2020

@bors r=@Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Oct 16, 2020

📌 Commit b221819 has been approved by mark-simulacrum

@bors bors 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.
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:master Oct 16, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 16, 2020
@jyn514 jyn514 deleted the broken-intra-doc-links branch November 7, 2020 18:19
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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: 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