Skip to content
Snippets Groups Projects
Commit 48699c83 authored by Victor Poughon's avatar Victor Poughon
Browse files

DOC: display alternative versions in the CookBook

parent a500f474
No related branches found
No related tags found
No related merge requests found
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Other Versions</span>
<span id="current-version-text"></span>
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Versions</dt>
<dd><a href="https://www.orfeo-toolbox.org/CookBook-6.2/">6.2.0</a></dd>
<dd><a href="https://www.orfeo-toolbox.org/CookBook-6.4/">6.4.0</a></dd>
<dd><a href="https://www.orfeo-toolbox.org/CookBook-6.6.1/">6.6.1</a></dd>
<dd><a href="https://www.orfeo-toolbox.org/CookBook-develop/">develop</a></dd>
</dl>
</div>
</div>
// This piece of javascript is used to display the versions widget at the lower
// left corner of the html CookBook for OTB
window.addEventListener('load', function() {
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE) {
if (request.status == 200) {
// Display the html div received with the AJAX request
document.body.insertAdjacentHTML('beforeend', request.responseText);
// Element showing version number in the header (made by sphinx)
var e = document.querySelector(".version");
// Element showing version number in the bottom left (the one we want)
var y = document.querySelector("#current-version-text");
if (e && y) {
// Swap them
y.innerHTML = "v: " + e.innerHTML;
e.remove();
}
} else {
console.log("Request for versions.html failed with HTTP ", request.status);
}
}
};
var versions_div_url = "_static/html/versions.html";
// If we are hosted on OTB website, get the latest version of the widget from
// develop so that past releases can show links to future ones
if (window.location.hostname == "www.orfeo-toolbox.org") {
versions_div_url = "https://www.orfeo-toolbox.org/CookBook-develop/_static/html/versions.html";
}
request.open('GET', versions_div_url);
request.send();
});
......@@ -22,9 +22,11 @@ import sphinx_rtd_theme
#sys.path.insert(0, os.path.abspath('.'))
# Customize read the docs theme a bit with a custom css
# and a custom version selection widget
# taken from https://stackoverflow.com/a/43186995/5815110
def setup(app):
app.add_stylesheet("css/otb_theme.css")
app.add_javascript("js/versions.js")
# -- General configuration ------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment