Skip to content

Add version warning banner for "latest" sphinx docs #1346

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 5 commits into from
Dec 10, 2021

Conversation

kandersolar
Copy link
Member

This PR adds a warning banner on latest docs pages using the method linked in #1260, i.e. checking the RTD metadata on page load and dynamically generating the banner if RTD indicates the page is in the latest version. That means that the banner won't show up in older docs versions or PR builds (both of which already get appropriate warning banners from RTD) and local builds (where it doesn't really matter anyway).

Because it won't show up on the PR build, I did a test build locally with the version check commented out (so that the banner is always generated) and here is the result:

image

"<p class='last'> " +
"This document is for an <strong>unreleased development version</strong>. " +
"Documentation is available for the <a href='/en/stable/'>current stable release</a>, " +
"or for older versions through the &ldquo;v:&rdquo; menu at bottom left." +
Copy link
Member Author

Choose a reason for hiding this comment

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

This text leaves the reader to infer that documentation for an "unreleased development version" may not be appropriate for their use case. Should we explicitly state this? Open to suggestions.

"Documentation is available for the <a href='/en/stable/'>current stable release</a>, " +
"or for older versions through the &ldquo;v:&rdquo; menu at bottom left." +
"</p>";
warning.querySelector('a').href = window.location.pathname.replace('/latest', '/stable');
Copy link
Member Author

@kandersolar kandersolar Nov 29, 2021

Choose a reason for hiding this comment

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

This line is a bit heavy-handed in that it replaces any and all instances (not just the relevant instance) of /latest with /stable in the url. So if we someday have a page that happens to contain an unrelated "/latest" (e.g. /en/latest/auto_examples/latest_CEC_modules.html or something), it would blindly edit both instances. I guess an easy improvement is to replace /en/latest with /en/stable. I guess the most robust fix would include some semantic understanding of URL structure. Maybe this is much ado about something that will probably never happen.

@wholmgren
Copy link
Member

Looks good to me.

Alternatively, readthedocs will let us hide the latest version. Does anyone use it other than developers?

@kandersolar
Copy link
Member Author

kandersolar commented Nov 30, 2021

Apparently they do; a quick look through a data dump of RTD's traffic analytics reveals that traffic to "latest" is ~1/10th that of "stable", and more than any numeric version. Numbers here are total page views since 2021-09-05.

0.1          393
latest     11911
stable    101172
v0.2.0       740
v0.2.1        41
v0.2.2       415
v0.3.0       123
v0.3.1        29
v0.3.2       252
v0.3.3        43
v0.4.0        10
v0.4.2        77
v0.4.3       161
v0.4.4         5
v0.4.5        69
v0.5.0        25
v0.5.1        12
v0.5.2        45
v0.6.0       787
v0.6.1       112
v0.6.2        53
v0.6.3       130
v0.7.2       145
v0.8.0       395
v0.8.1       144
v0.9.0      2630

It's tangential to this PR, but anyone have an explanation for the nontrivial amount of traffic going to versions as old as 0.1 and 0.2.x?

@cwhanse
Copy link
Member

cwhanse commented Nov 30, 2021

v0.7 dropped support for python 2.7, and in v0.6 we deprecated a number of functions for renaming or replacement. Maybe the traffic on v0.6.0 docs is for users who have decided not to update their code.

The traffic for 0.2 is perplexing.

@kandersolar
Copy link
Member Author

Needed a couple updates for #1173. I'll merge this in a couple days unless anyone objects.

This is what it looks like now:

image

@wholmgren wholmgren added this to the 0.9.1 milestone Dec 8, 2021
Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

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

Do we need to include the BSD3 license of either source?

@kandersolar
Copy link
Member Author

Do we need to include the BSD3 license of either source?

Done, thanks for the reminder!

@kandersolar kandersolar merged commit 797ce05 into pvlib:master Dec 10, 2021
@kandersolar kandersolar deleted the latest_banner branch December 10, 2021 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"latest" docs don't make it clear that they contain unreleased features
3 participants