forked from Unidata/MetPy
-
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.
ENH: Add javacript to dynamically populate version chooser
This reads a versions.json from the root of the documentation repository to determine what versions are available. Set up this json file to be created during documentation deployment.
- Loading branch information
1 parent
ba77131
commit cf7d532
Showing
4 changed files
with
35 additions
and
2 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
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,11 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) 2017 MetPy Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
"""Generate versions.json from directory with different doc versions.""" | ||
|
||
import glob | ||
|
||
with open('versions.json', 'wt') as version_file: | ||
version_strings = ','.join('"{}"'.format(d) for d in glob.glob('v*.[0-9]*')) | ||
version_file.write('{"versions":["latest","dev",' + version_strings + ']}\n') |
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,17 @@ | ||
$(document).ready(function() { | ||
var proj_end = document.baseURI.indexOf("MetPy") + 6; | ||
var end = document.baseURI.indexOf("/", proj_end); | ||
var cur_ver = document.baseURI.substring(proj_end, end); | ||
var name = cur_ver.startsWith('v') ? cur_ver.substring(1) : cur_ver; | ||
var mylist = $("#version-list"); | ||
mylist.empty(); | ||
mylist.append($("<option>", {value: "../" + cur_ver, text: name})); | ||
$.getJSON("../versions.json", function(obj) { | ||
$.each(obj.versions, function() { | ||
if (this != cur_ver) { | ||
name = this.startsWith('v') ? this.substring(1) : this; | ||
mylist.append($("<option>", {value: "../" + this, text: 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