Skip to content

Commit

Permalink
[Docs] Warn latest is unstable (#101)
Browse files Browse the repository at this point in the history
* docs

* docs

* docs
  • Loading branch information
matteobettini authored Jun 17, 2024
1 parent 11c55c2 commit 2a337e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
27 changes: 27 additions & 0 deletions docs/source/_static/js/version_alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*
*/

function warnOnLatestVersion() {
if (!window.READTHEDOCS_DATA || window.READTHEDOCS_DATA.version !== "latest") {
return; // not on ReadTheDocs and not latest.
}

var note = document.createElement('div');
note.setAttribute('class', 'admonition note');
note.innerHTML = "<p class='first admonition-title'>Note</p> " +
"<p> " +
"This documentation is for an <b>unreleased development version</b>. " +
"Click <a href='/en/stable'><b>here</b></a> to access the documentation of the current stable release." +
"</p>";

var parent = document.querySelector('#benchmarl');
if (parent)
parent.insertBefore(note, parent.querySelector('h1'));
}

document.addEventListener('DOMContentLoaded', warnOnLatestVersion);
6 changes: 5 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
intersphinx_disabled_domains = ["std"]

templates_path = ["_templates"]
html_static_path = [osp.join(osp.dirname(benchmarl_sphinx_theme.__file__), "static")]
html_static_path = [
osp.join(osp.dirname(benchmarl_sphinx_theme.__file__), "static"),
"_static",
]


html_theme = "sphinx_rtd_theme"
Expand All @@ -65,3 +68,4 @@ def rst_jinja_render(app, _, source):
source[0] = app.builder.templates.render_string(source[0], rst_context)

app.connect("source-read", rst_jinja_render)
app.add_js_file("js/version_alert.js")

0 comments on commit 2a337e8

Please sign in to comment.