-
Notifications
You must be signed in to change notification settings - Fork 645
Do not attempt to overwrite docs.rs link. #1207
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
def8ac1
to
a69a5d0
Compare
@DoumanAsh Thanks for your work on this issue, I'm sorry for the trouble it might have caused. I cloned your repository and did some tests, unfortunately it contains a bug that was fixed by the line you removed: when you change the crate's version, the documentation link is not correctly updated. I assembled a patch that should fix the original issue while not breaking anything, feel free to test it and integrate it in your branch: diff --git a/app/routes/crate/version.js b/app/routes/crate/version.js
index 79835c38..6c8189e4 100644
--- a/app/routes/crate/version.js
+++ b/app/routes/crate/version.js
@@ -41,13 +41,16 @@ export default Route.extend({
};
const fetchCrateDocumentation = () => {
- if (!crate.get('documentation')) {
- let crateName = crate.get('name');
- let crateVersion = params.version_num;
+ if (!crate.get('documentation') ||
+ crate.get('documentation').substr(0, 16) === 'https://docs.rs/') {
+ const crateName = crate.get('name');
+ const crateVersion = params.version_num;
+ const docsURL = `https://docs.rs/${crateName}/${crateVersion}/`;
+ const docsPlatform = (crate.get('documentation') || docsURL).slice(16).split('/').slice(2).join('/');
this.get('ajax').request(`https://docs.rs/crate/${crateName}/${crateVersion}/builds.json`)
.then((r) => {
if (r.length > 0 && r[0].build_status === true) {
- crate.set('documentation', `https://docs.rs/${crateName}/${crateVersion}/`);
+ crate.set('documentation', `${docsURL}${docsPlatform}`);
}
});
} |
@kureuil I'm a bit confused. Your solution will make no sense for #1206 as you still overwrote author's link. A better solution would be to clear out Generally I would prefer remove this docs.rs 'integration' from front-end and moving it to back-end itself. P.s. another thing it would be better to not update original P.s. 2 Is |
a69a5d0
to
a9fe088
Compare
We need to check with docs.rs to make sure there is a successful build of documentation before we link to it. I'm ok moving that check from the client side to the server side, but the check is important because we don't want to link to docs that are broken or missing. |
@carols10cents I believe it is author responsibility to provide valid link to documentation. There is though another option: Provide extra link to docs.rs if author specified own link. |
The intent of this feature was to only link to docs.rs if the author has not specified a link. |
Yes, that's why I removed this check But according to @kureuil it is necessary to prevent UI bug on switching versions. |
app/routes/crate/version.js
Outdated
@@ -15,6 +15,7 @@ export default Route.extend({ | |||
async model(params) { | |||
const requestedVersion = params.version_num === 'all' ? '' : params.version_num; | |||
const crate = this.modelFor('crate'); | |||
const original_docs = crate.get('documentation'); |
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.
Could you please use camelcase as the rest of variables do in the javascript project (we should have a linter roule for this, I know)
If original link is missing then attribute 'documentation' is updated with actual link to docs.rs
a9fe088
to
cba8a04
Compare
I added to model a separate attribute to store original link to docs. Since I cannot install sass, i'd appreciate someone to check it out to be sure |
@carols10cents ping? |
Current overwrite from |
@nagisa But it also currently overwrites from I would be okay with a modification that makes it preserve the |
Yeah, to me it seems like involving the |
@nagisa From what I understand current behavior is not intentional but consequence of bad implementation. It could be obviously done, but it makes sense to do it on server side, rather than doing it each time on client side. |
Review plz? |
I would accept a PR to do docs.rs documentation URL detection/manipulation on the server side. Because you seem to think that would be a better way as well, I'm going to close this PR. Thanks! |
Subj to fix #1206 issue
P.s. a better solution should be done to perform update on back-end once that would handle all variants of docs.rs links