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

Fragment errors are reported for redirect pages #120

Closed
bugadani opened this issue Nov 25, 2020 · 5 comments · Fixed by #131
Closed

Fragment errors are reported for redirect pages #120

bugadani opened this issue Nov 25, 2020 · 5 comments · Fixed by #131
Labels
C-enhancement Category: This is a new feature help wanted

Comments

@bugadani
Copy link

When a type is exported in a prelude, rustdoc sometimes generates a redirection page. Funny enough, sometimes the destination page is in the prelude module, but this issue is not about that.

deadlinks doesn't follow redirection pages and reports Fragment #... at ... does not exist! errors. An example of this can be found here: https://github.com/embedded-graphics/embedded-text/runs/1453160019?check_suite_focus=true - in this case the fragment exists at embedded_graphics/prelude/trait.DrawTarget.html#associatedtype.Error

@bugadani bugadani changed the title Fragment errors don't consider redirect pages Fragment errors are reported for redirect pages Nov 25, 2020
@jyn514
Copy link
Contributor

jyn514 commented Nov 25, 2020

How can I reproduce this error? I tried checking out that branch and running cargo deadlinks, which gave me

Found invalid urls in struct.TextBox.html:
	Fragment #tymethod.translate_mut at /home/joshua/.local/lib/cargo/target/doc/embedded_text/struct.TextBox.html does not exist!
Found invalid urls in struct.StyledTextBox.html:
	Fragment #tymethod.translate_mut at /home/joshua/.local/lib/cargo/target/doc/embedded_text/struct.StyledTextBox.html does not exist!

Both of those errors seem to be correct, they're broken links generated by rustdoc (rust-lang/rust#74222).

@bugadani
Copy link
Author

bugadani commented Nov 25, 2020

Huh, I don't have the errors you have. Strange, I have this issue with the 11-24 nightly rustc, are you using something else? Locally I have the same output as I linked in CI - I did nothing more than checking out master and running cargo deadlinks.

Ugh this is fishy, I have the same as you on a different windows PC. Let me investigate a bit.

@bugadani
Copy link
Author

bugadani commented Nov 25, 2020

@jyn514

cargo doc
cargo deadlinks [--no-build]

is not equivalent to cargo deadlinks. The former reproduces my output, the latter gives me yours. I guess deadlinks skips documenting the external crates?

@jyn514
Copy link
Contributor

jyn514 commented Nov 25, 2020

@bugadani yes, cargo deadlinks passes --no-deps. That's the recommended way to use deadlinks, since otherwise you get link failures from your dependencies too.

@jyn514
Copy link
Contributor

jyn514 commented Nov 26, 2020

Ok I see, I can reproduce now.

This is tricky to fix in general, since it requires knowing whether arbitrary HTML/JS will redirect to another page, independent of HTTP status codes. Fortunately it doesn't need to work in general, it only needs to work for the pages rustdoc generates, which look like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="refresh" content="0;URL=../../embedded_graphics/prelude/trait.DrawTarget.html">
</head>
<body>
    <p>Redirecting to <a href="../../embedded_graphics/prelude/trait.DrawTarget.html">../../embedded_graphics/prelude/trait.DrawTarget.html</a>...</p>
    <script>location.replace("../../embedded_graphics/prelude/trait.DrawTarget.html" + location.search + location.hash);</script>
</body>
</html>

I think a sufficient workaround is to look for <meta http-equiv=refresh content="URL=xxx"> and follow the redirect if so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: This is a new feature help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants