Skip to content

Commit 11e5e99

Browse files
committed
Add docs.rs integration
When a crate does not specify a documentation link, we query docs.rs to know if the documentation for the requested version was successfully built. If if is, we set the crate's documentation link to the corresponding docs.rs page, if not nothing changes.
1 parent 6f71d1d commit 11e5e99

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/routes/crate/version.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ export default Ember.Route.extend({
6868
.finally(() => controller.set('fetchingFollowing', false));
6969
}
7070

71+
if (!crate.get('documentation')) {
72+
let crateName = crate.get('name');
73+
let crateVersion = params.version_num;
74+
ajax(`https://docs.rs/crate/${crateName}/${crateVersion}/builds.json`)
75+
.then((r) => {
76+
if (r.length > 0 && r[0].build_status === true) {
77+
crate.set('documentation', `https://docs.rs/${crateName}/${crateVersion}/${crateName}/`);
78+
}
79+
});
80+
}
81+
7182
// Find version model
7283
return crate.get('versions')
7384
.then(versions => {

0 commit comments

Comments
 (0)