-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 1 commit
64bc094
def6e3b
f215e79
d6f006a
01bec0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| "use strict"; | ||
|
|
||
| // Source: | ||
| // https://github.com/anymail/django-anymail/blob/4c443f5515d1d5269a95cb54cf75057c56a3b150/docs/_static/version-alert.js | ||
| // via: | ||
| // https://github.com/qucontrol/krotov/blob/969fc980346e6411903de854118c48c51208a810/docs/_static/version-alert.js | ||
| // following instructions here: | ||
| // https://michaelgoerz.net/notes/showing-a-warning-for-the-latest-documentation-on-readthedocs.html | ||
|
|
||
| function warnOnLatestVersion() { | ||
|
|
||
| // The warning text and link is really specific to RTD hosting, | ||
| // so we can just check their global to determine version: | ||
| if (!window.READTHEDOCS_DATA || window.READTHEDOCS_DATA.version !== "latest") { | ||
| return; // not latest, or not on RTD | ||
| } | ||
|
|
||
| var warning = document.createElement('div'); | ||
| warning.setAttribute('class', 'admonition danger'); | ||
| warning.innerHTML = "<p class='first admonition-title'>Note</p> " + | ||
| "<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 “v:” menu at bottom left." + | ||
| "</p>"; | ||
| warning.querySelector('a').href = window.location.pathname.replace('/latest', '/stable'); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| var parent = document.querySelector('div.body') | ||
| || document.querySelector('div.document') | ||
| || document.body; | ||
| parent.insertBefore(warning, parent.firstChild); | ||
| } | ||
|
|
||
| document.addEventListener('DOMContentLoaded', warnOnLatestVersion); | ||
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.
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.