File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ // Similar to https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/core/static-src/core/js/doc-embed/version-compare.js
4+ // but adds admonition for the "latest" version -- which is (unreleased) master branch.
5+
6+ function warnOnLatestVersion ( ) {
7+
8+ // The warning text and link is really specific to RTD hosting,
9+ // so we can just check their global to determine version:
10+ if ( ! window . READTHEDOCS_DATA || window . READTHEDOCS_DATA . version !== "latest" ) {
11+ return ; // not latest, or not on RTD
12+ }
13+
14+ var warning = document . createElement ( 'div' ) ;
15+ warning . setAttribute ( 'class' , 'admonition danger' ) ;
16+ warning . innerHTML = "<p class='first admonition-title'>Note</p> " +
17+ "<p class='last'> " +
18+ "This document is for an <strong>unreleased development version</strong>. " +
19+ "Documentation is available for the <a href='/en/stable/'>current stable release</a>, " +
20+ "or for older versions through the “v:” menu at bottom left." +
21+ "</p>" ;
22+ warning . querySelector ( 'a' ) . href = window . location . pathname . replace ( '/latest' , '/stable' ) ;
23+
24+ var parent = document . querySelector ( 'div.body' )
25+ || document . querySelector ( 'div.document' )
26+ || document . body ;
27+ parent . insertBefore ( warning , parent . firstChild ) ;
28+ }
29+
30+ document . addEventListener ( 'DOMContentLoaded' , warnOnLatestVersion ) ;
Original file line number Diff line number Diff line change 1+ {% extends "!layout.html" %}
2+
3+ {% set script_files = script_files + ["_static/version-alert.js"] %}
You can’t perform that action at this time.
0 commit comments