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

Conversation

jnothman
Copy link
Member

@jnothman jnothman commented Aug 8, 2019

This script would be available to work with the following change to all HTML files here:

$ find */ -name "*.html" | xargs sed -i '/<\/body>/ i \
\    <script src="https://scikit-learn.org/versionwarning.js"></script>'

It produces banners like the following on the dev version:

image

and the following on older versions:

image

Inserting the script would be done in another PR, and as a change in our Circle CI doc deployment.

To do after merge:

@jnothman
Copy link
Member Author

jnothman commented Aug 8, 2019

I think the wording and styling could benefit from some improvements. But because it's not embedded in the HTML, some of that can be improved over time.

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

This is quite nice! The warnings I was mentioning is for instance https://flask.palletsprojects.com/en/1.0.x/ there it's done by statically injecting this header into HTML by ReadTheDocs as far as I can tell.

I like that it's single JS file used everywhere that we can always change later. One limitations is that web crawlers may not see it if they don't render JS, but I guess we already have a link in the menu to the stable docs so that should be enough.

One caveat is that we need to remember to re-run the sed script for any commit on the released branches. I think we should add it on the CircleCI deploy job for non master branches.

showWarning('You are looking at documentation for an old release of ' +
'Scikit-learn (version ' + versionPath + '). Try the ' +
'<a href="https://scikit-learn.org">latest release</a> 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

@rth
Copy link
Member

rth commented Aug 8, 2019

Do you want to run the sed command in this PR or a separate one?

@jnothman
Copy link
Member Author

jnothman commented Aug 8, 2019 via email

@jnothman
Copy link
Member Author

Updates:
image

image

@adrinjalali
Copy link
Member

Nice, I like this one, shall we merge?

@NicolasHug
Copy link
Member

shall we merge?

+1, I haven't reviewed the JS but I like the messages too

@adrinjalali adrinjalali merged commit 605d3f9 into master Aug 12, 2019
@jnothman
Copy link
Member Author

Now live on non-dev versions. https://scikit-learn.org/0.20/

adrinjalali pushed a commit to scikit-learn/scikit-learn that referenced this pull request Aug 14, 2019
'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

@adrinjalali adrinjalali deleted the versionwarning-script-only branch September 28, 2021 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants