diff --git a/.gitignore b/.gitignore
index a5de41ba388c..841d616a69d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,5 +49,6 @@ regression/local_test_setup
# Make sure a generated file isn't accidentally committed.
pylintrc_reduced
-# Wheel directory used in Travis builds.
+# Travis build directories.
gcloud-python-wheels/
+ghpages/
diff --git a/scripts/update_docs.sh b/scripts/update_docs.sh
index b4b4e8a67389..ef76d04afc5a 100755
--- a/scripts/update_docs.sh
+++ b/scripts/update_docs.sh
@@ -51,6 +51,11 @@ else
# Put the new release in latest and with the actual version.
cp -R ../docs/_build/html/ latest/
cp -R ../docs/_build/html/ "${CURRENT_VERSION}/"
+
+ # Also update the versions file.
+ .tox/docs/bin/python ../scripts/update_versions.py
+ # Update the files which were updated in the release.
+ git add versions.html versions.json
fi
# Update the files push to gh-pages.
diff --git a/scripts/update_versions.py b/scripts/update_versions.py
new file mode 100644
index 000000000000..d1badd3bc299
--- /dev/null
+++ b/scripts/update_versions.py
@@ -0,0 +1,49 @@
+import json
+import os
+from pkg_resources import get_distribution
+
+
+LI_TEMPLATE = '
%s'
+SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
+GH_PAGES_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', 'ghpages'))
+VERSIONS_TMPL = os.path.join(SCRIPTS_DIR, 'versions.html.template')
+JSON_VERSIONS = os.path.join(GH_PAGES_DIR, 'versions.json')
+VERSIONS_FILE = os.path.join(GH_PAGES_DIR, 'versions.html')
+
+
+def update_versions(new_version):
+ with open(JSON_VERSIONS, 'r') as file_obj:
+ versions = json.load(file_obj)
+
+ if new_version in versions:
+ return versions
+
+ versions.insert(0, new_version)
+
+ with open(JSON_VERSIONS, 'w') as file_obj:
+ json.dump(versions, file_obj)
+
+ return versions
+
+
+def render_template(new_version):
+ versions = update_versions(new_version)
+
+ with open(VERSIONS_TMPL, 'r') as file_obj:
+ page_template = file_obj.read()
+
+ versions_list = '\n'.join([LI_TEMPLATE % (version, version)
+ for version in versions])
+
+ return page_template.format(versions=versions_list)
+
+
+def main():
+ new_version = get_distribution('gcloud').version
+ rendered = render_template(new_version)
+ with open(VERSIONS_FILE, 'w') as file_obj:
+ file_obj.write(rendered)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/versions.html.template b/scripts/versions.html.template
new file mode 100644
index 000000000000..6be806d2d682
--- /dev/null
+++ b/scripts/versions.html.template
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+ gcloud-python Versions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+