-
Notifications
You must be signed in to change notification settings - Fork 684
Add a link to browse crate source on docs.rs #12550
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| get docsRsSourceLink() { | ||
| if (this.hasDocsRsLink) { | ||
| return `https://docs.rs/crate/${this.crateName}/${this.num}/source/`; |
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.
I think we can show the link more often.
from what I see, hasDocsRsLink is based on our status-json result (doc_status in there).
But we also have & host the source when:
- it's a binary crate, or
- the if the doc-build failed
- when the build is in progress
The only edge cases here would be when the build is queued, or we didn't get the update from the registry yet.
I think you're good in just checking if you have a result from our status endpoint, no matter what you see in doc_status
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.
there is also rust-lang/docs.rs#2762 where we would try to serve a nice page even for just queued releases
c583304 to
bf6d458
Compare
Don't show the link if there aren't any docs.rs builds as clicking on the link won't work then, but do still show the source link even if a non-docs.rs documentation link has been specified to enable review of the source exactly as crates.io serves it.
19002b9 to
339991b
Compare
|
@Turbo87 i quit. I can't figure out why the remaining one qunit and one e2e tests are failing; i added the mock docs.rs requests exactly like in the other tests that are passing, but the source link isn't showing up and I don't understand why. The source link is showing up in some of the percy screenshots as expected, but it also looks like the main baseline in percy has some 404 pages saved? I also can't get the frontend working locally proxying to the live crates.io; when I run the frontend everything looks fine: but when i visit localhost:4200/crates/rand for example, it shows the "Failed to load crate data" generic javascript error message (in both firefox and chrome). In firefox, there aren't any errors showing up in the web development tools console, but if i open tools -> browser tools -> browser console, i see: and in chrome i don't see any console errors:
if I make this change in app/routes/crate.js: } catch (error) {
if (error instanceof NotFoundError) {
let title = `Crate "${crateName}" not found`;
this.router.replaceWith('catch-all', { transition, error, title });
} else {
console.log(error);
let title = `Failed to load crate data`;
this.router.replaceWith('catch-all', { transition, error, title, tryAgain: true });
}
}THEN i see: which... wtf????? what am i doing wrong????????? |
|
oh ffs nevermind... i did the good old "blow away node_modules" and now i can load a local page proxying to crates.io. |
|
ok yeah even with getting this running locally i still dont understand why this code isn't working. if i go to a crate like rand that doesn't have if i go to a crate like ripgrep that does have |
|
I'll take a look once I'm back at a computer :) |

Don't show the link if there aren't any docs.rs builds as clicking on the link won't work then, but do still show the source link even if a non-docs.rs documentation link has been specified to enable review of the source exactly as crates.io serves it.