forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change html build to make versioned documentation with a dropdown menu
This changes the documentation theme to use the readthedocs theme, with some JavaScript that provides capabilities for a dropdown menu allowing you to select between different versions. This mimics the changes in ESMCI/cime#3439, which in turn was based on ESCOMP/CISM-wrapper#23.
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
$(document).ready(function() { | ||
/* For a URL that looks like | ||
https://blah.github.io/versions/VERSIONFOO/html/bar/index.html, set cur_version_dir to | ||
'VERSIONFOO' (i.e., the portion of the path following 'versions'). | ||
*/ | ||
var proj_end = document.baseURI.indexOf("versions") + 9; | ||
var end = document.baseURI.indexOf("/", proj_end); | ||
var cur_version_dir = document.baseURI.substring(proj_end, end); | ||
var mylist = $("#version-list"); | ||
mylist.empty(); | ||
$.getJSON(version_json_loc, function(data) { | ||
if (data.hasOwnProperty(cur_version_dir)) { | ||
/* First add the current version so that it appears first in the drop-down | ||
menu and starts as the selected element of the menu. If you click on the | ||
current version, you should stay at the current page. | ||
The conditional around this block should generally be true, but we check it | ||
just in case the current version is missing from the versions.json file for | ||
some reason. | ||
*/ | ||
cur_version_name = data[cur_version_dir]; | ||
mylist.append($("<option>", {value: document.baseURI, text: cur_version_name})); | ||
} | ||
// Now add the other versions | ||
$.each(data, function(version_dir, version_name) { | ||
if (version_dir != cur_version_dir) { | ||
/* If you click on a different version, you should go to the root of the | ||
documentation for that version. This assumes paths like | ||
https://blah.github.io/versions/VERSIONFOO/html/bar/index.html. So we | ||
need to go up two levels from the URL_ROOT (html) to then go back down | ||
into the appropriate version's html directory. | ||
*/ | ||
mylist.append($("<option>", {value: DOCUMENTATION_OPTIONS.URL_ROOT + '../../' + version_dir + '/html', text: version_name})); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends "!footer.html" %} | ||
{% block extrafooter %} | ||
{{ super() }} | ||
<script>var version_json_loc = "{{ pathto('../../versions.json', 1) }}";</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% extends "!layout.html" %} | ||
|
||
{% set script_files = script_files + ["_static/pop_ver.js"] %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters