Skip to content

Commit 605d3f9

Browse files
authored
MNT Script to warn when viewing version other than stable
Script to warn when viewing version other than stable
2 parents a7ccc6e + a7a540a commit 605d3f9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

versionwarning.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(function() {
2+
var latestStable = '0.21';
3+
var goodPaths = ['stable', 'dev', latestStable];
4+
var showWarning = (msg) => {
5+
$('.body[role=main]').prepend(
6+
'<p style="' +
7+
[
8+
'padding: 1em',
9+
'font-size: 1.5em',
10+
'border: 1px solid red',
11+
'background: pink',
12+
'width: 100%',
13+
].join('; ') +
14+
'">' + msg + '</p>')
15+
};
16+
if (location.hostname == 'scikit-learn.org') {
17+
var versionPath = location.pathname.split('/')[1];
18+
if (!goodPaths.includes(versionPath)) {
19+
showWarning('This is documentation for an old release of ' +
20+
'Scikit-learn (version ' + versionPath + '). Try the ' +
21+
'<a href="https://scikit-learn.org">latest stable ' +
22+
'release</a> (version ' + latestStable + ') or ' +
23+
'<a href="https://scikit-learn.org/dev">development</a> ' +
24+
'(unstable) versions.')
25+
} else if (versionPath == 'dev') {
26+
showWarning('This is documentation for the unstable ' +
27+
'development version of Scikit-learn. (To use it, ' +
28+
'<a href="https://scikit-learn.org/stable/developers/advanced_installation.html#installing-nightly-builds">install the nightly build</a>.) ' +
29+
'The latest stable ' +
30+
'release is <a href="https://scikit-learn.org">version ' +
31+
latestStable + '</a>.')
32+
}
33+
}
34+
})()

0 commit comments

Comments
 (0)