Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
15 changes: 15 additions & 0 deletions scripts/get_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Simple script to get the gcloud version."""

from pkg_resources import get_distribution
print get_distribution('gcloud').version
5 changes: 5 additions & 0 deletions scripts/update_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
83 changes: 83 additions & 0 deletions scripts/update_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Simple script to update the gcloud versions list and file."""

import json
import os
from pkg_resources import get_distribution


LI_TEMPLATE = '<li><a href="%s/index.html">%s</a></li>'
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):
"""Updates JSON file with list of versions.

Reads and writes JSON to ``JSON_VERSIONS`` file. Does not write
if ``new_version`` is already contained.

:type new_version: string
:param new_version: New version being added.

:rtype: list of strings
:returns: List of all versions.
"""
with open(JSON_VERSIONS, 'r') as file_obj:
versions = json.load(file_obj)

if new_version not in 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):
"""Renders static versions page.

:type new_version: string
:param new_version: New version being added.

:rtype: string
:returns: Rendered versions page.
"""
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():
"""Creates new versions.html template."""
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()
100 changes: 100 additions & 0 deletions scripts/versions.html.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>gcloud-python Versions</title>

<link rel="stylesheet" href="_landing-page-static/css/docs-main.css" type="text/css" />
<link rel="stylesheet" href="_landing-page-static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_landing-page-static/css/normalize.css" type="text/css" />
<link rel="stylesheet" href="_landing-page-static/css/github.min.css" type="text/css" />

<script type="text/javascript" src="_landing-page-static/js/vendor/modernizr-2.6.2.min.js"></script>
<link rel="shortcut icon" href="_landing-page-static/favicon.ico"/>
<link rel="top" title="gcloud-python Versions" href="#" />
</head>
<body>
<header class="page-header fixed" role="banner">
<h1 class="logo">
<a href="index.html" title="back to home">
<img src="_landing-page-static/images/logo.svg" alt="Google Cloud Platform" />
<span class="gcloud">gcloud</span>
</a>
</h1>
<nav class="main-nav">
<div class="nav-current">Python</div>
<ul class="menu">
<li>
<a href="
https://googlecloudplatform.github.io/gcloud-node" title="Node.js docs page">
<img src="_landing-page-static/images/icon-lang-nodejs.svg" alt="Node.js icon" class="menu-icon" />
Node.js
</a>
</li>
<li>
<a href="#" title="Python docs page">
<img src="_landing-page-static/images/icon-lang-python-white.svg" alt="Python icon" class="menu-icon" />
Python
</a>
</li>
</ul>
</nav><!-- end of .main-nav -->
</header><!-- end of .page-header -->

<article class="main lang-page" role="main">

<header class="docs-header">
<h1 class="page-title">Versions</h1>
</header>

<section class="content">

<div class="toctree-wrapper compound">
</div>
<ul id="versions">
{versions}
</ul>

</section><!-- end of .content -->
<nav class="side-nav">
<ul><li><a href="latest/index.html">Documentation</a></li></ul>
<ul class="simple">
</ul>

<ul class="external-links">
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python/" title="Python on Github">
<img src="_landing-page-static/images/icon-link-github.svg" alt="Github icon" />
Github
</a>
</li>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python/issues" title="Python issues on Github">
<img src="_landing-page-static/images/icon-link-github.svg" alt="Github icon" />
Issues
</a>
</li>
<li>
<a href="http://stackoverflow.com/questions/tagged/gcloud-python" title="gcloud on StackOverflow">
<img src="_landing-page-static/images/icon-link-stackoverflow.svg" alt="StackOverflow icon" />
gcloud
</a>
</li>
<li>
<a href="https://pypi.python.org/pypi/gcloud" title="Python package manager">
<img src="_landing-page-static/images/icon-link-package-manager.svg" alt="Package Manager icon" />
Package Manager
</a>
</li>
</ul>
</nav><!-- end of .side-nav -->
</article><!-- end of .main -->

<script src="_landing-page-static/js/vendor/jquery-1.10.2.min.js"></script>
<script src="_landing-page-static/js/plugins.js"></script>
<script src="_landing-page-static/js/main.js"></script>

</body>
</html>