Skip to content

Script to warn when viewing version other than stable #13

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

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions versionwarning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function() {
var latestStable = '0.21';
var goodPaths = ['stable', 'dev', latestStable];
var showWarning = (msg) => {
$('.body[role=main]').prepend(
'<p style="' +
[
'padding: 1em',
'font-size: 1.5em',
'border: 1px solid red',
'background: pink',
'width: 100%',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific line makes the box non mobile-phone friendly (it creates a horizontal scroll by extending out of the viewport). It is not needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened the following PR to address this problem: #14

].join('; ') +
'">' + msg + '</p>')
};
if (location.hostname == 'scikit-learn.org') {
var versionPath = location.pathname.split('/')[1];
if (!goodPaths.includes(versionPath)) {
showWarning('This is documentation for an old release of ' +
'Scikit-learn (version ' + versionPath + '). Try the ' +
'<a href="https://scikit-learn.org">latest stable ' +
'release</a> (version ' + latestStable + ') or ' +
'<a href="https://scikit-learn.org/dev">development</a> ' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure for putting the dev on outdated versions. Few users need it and it can lead to confusion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, the dev version would be nice if we also tell people that they can have it through the nightly wheels. We would also get more testers before the release that way. I wouldn't mind that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that the warning shown on dev should point the user to installation instructions? Nice idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @rth about not strictly encouraging the dev docs. Maybe we can make it clearer with

Try the latest stable release (recommended) or the development version (unstable).

And yes linking to installation instructions on the dev version would be great too

'(unstable) versions.')
} else if (versionPath == 'dev') {
showWarning('This is documentation for the unstable ' +
'development version of Scikit-learn. (To use it, ' +
'<a href="https://scikit-learn.org/stable/developers/advanced_installation.html#installing-nightly-builds">install the nightly build</a>.) ' +
'The latest stable ' +
'release is <a href="https://scikit-learn.org">version ' +
latestStable + '</a>.')
}
}
})()