Skip to content

Commit ad6c065

Browse files
author
travis-ci
committed
Switch back to Sphinx.
1 parent 92219b8 commit ad6c065

File tree

6 files changed

+296
-1
lines changed

6 files changed

+296
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ script:
1313
- tox -e system-tests
1414
- tox -e system-tests3
1515
- tox -e docs
16+
- scripts/update_docs.sh
1617

1718
after_success:
1819
- tox -e coveralls

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Google Cloud Python Client
1111
- `API Documentation`_
1212

1313
.. _Homepage: https://googlecloudplatform.github.io/google-cloud-python/
14-
.. _API Documentation: http://googlecloudplatform.github.io/google-cloud-python/#/docs/master/google-cloud
14+
.. _API Documentation: http://googlecloudplatform.github.io/google-cloud-python/
1515

1616
This client supports the following Google Cloud Platform services:
1717

scripts/get_version.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2014 Google Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Simple script to get the gcloud version."""
16+
17+
from pkg_resources import get_distribution
18+
print get_distribution('google-cloud').version

scripts/update_docs.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
# Copyright 2014 Google Inc. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -ev
18+
19+
#########################################
20+
# Only update docs if we are on Travis. #
21+
#########################################
22+
if [[ "${TRAVIS_BRANCH}" == "master" ]] && \
23+
[[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then
24+
echo "Building new docs on a merged commit."
25+
elif [[ -n "${TRAVIS_TAG}" ]]; then
26+
echo "Building new docs on a tag."
27+
else
28+
echo "No docs to update for a new tag or merged commit on Travis."
29+
echo "Verifying docs build successfully."
30+
tox -e docs
31+
exit
32+
fi
33+
34+
# Adding GitHub pages branch. `git submodule add` checks it
35+
# out at HEAD.
36+
GH_PAGES_DIR="ghpages"
37+
git submodule add -b gh-pages \
38+
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \
39+
${GH_PAGES_DIR}
40+
41+
# Determine if we are building a new tag or are building docs
42+
# for master. Then build new docset in docs/_build from master.
43+
if [[ -z "${TRAVIS_TAG}" ]]; then
44+
SPHINX_RELEASE=$(git log -1 --pretty=%h) tox -e docs
45+
else
46+
# Sphinx will use the package version by default.
47+
tox -e docs
48+
fi
49+
50+
# Get the current version. Assumes the PWD is the root of the git repo.
51+
# We run this after `tox -e docs` to make sure the `docs` env is
52+
# set up.
53+
CURRENT_VERSION=$(.tox/docs/bin/python scripts/get_version.py)
54+
55+
# Update gh-pages with the created docs.
56+
cd ${GH_PAGES_DIR}
57+
if [[ -z "${TRAVIS_TAG}" ]]; then
58+
git rm -fr latest/
59+
cp -R ../docs/_build/html/ latest/
60+
else
61+
if [[ -d ${CURRENT_VERSION} ]]; then
62+
echo "The directory ${CURRENT_VERSION} already exists."
63+
exit 1
64+
fi
65+
git rm -fr stable/
66+
# Put the new release in stable and with the actual version.
67+
cp -R ../docs/_build/html/ stable/
68+
cp -R ../docs/_build/html/ "${CURRENT_VERSION}/"
69+
70+
# Also update the versions file.
71+
../.tox/docs/bin/python ../scripts/update_versions.py
72+
# Update the files which were updated in the release.
73+
git add versions.html versions.json
74+
fi
75+
76+
# Update the files push to gh-pages.
77+
git add .
78+
git status
79+
80+
# H/T: https://github.com/dhermes
81+
if [[ -z "$(git status --porcelain)" ]]; then
82+
echo "Nothing to commit. Exiting without pushing changes."
83+
exit
84+
fi
85+
86+
# Commit to gh-pages branch to apply changes.
87+
git config --global user.email "travis@travis-ci.org"
88+
git config --global user.name "travis-ci"
89+
git commit -m "Update docs after merge to master."
90+
# NOTE: This may fail if two docs updates (on merges to master)
91+
# happen in close proximity.
92+
git push \
93+
"https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \
94+
HEAD:gh-pages

scripts/update_versions.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright 2014 Google Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Simple script to update the google-cloud-python versions list and file."""
16+
17+
import json
18+
import os
19+
from pkg_resources import get_distribution
20+
21+
22+
LI_TEMPLATE = '<li><a href="%s/index.html">%s</a></li>'
23+
SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
24+
GH_PAGES_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', 'ghpages'))
25+
VERSIONS_TMPL = os.path.join(SCRIPTS_DIR, 'versions.html.template')
26+
JSON_VERSIONS = os.path.join(GH_PAGES_DIR, 'versions.json')
27+
VERSIONS_FILE = os.path.join(GH_PAGES_DIR, 'versions.html')
28+
29+
30+
def update_versions(new_version):
31+
"""Updates JSON file with list of versions.
32+
33+
Reads and writes JSON to ``JSON_VERSIONS`` file. Does not write
34+
if ``new_version`` is already contained.
35+
36+
:type new_version: string
37+
:param new_version: New version being added.
38+
39+
:rtype: list of strings
40+
:returns: List of all versions.
41+
"""
42+
with open(JSON_VERSIONS, 'r') as file_obj:
43+
versions = json.load(file_obj)
44+
45+
if new_version not in versions:
46+
versions.insert(0, new_version)
47+
48+
with open(JSON_VERSIONS, 'w') as file_obj:
49+
json.dump(versions, file_obj)
50+
51+
return versions
52+
53+
54+
def render_template(new_version):
55+
"""Renders static versions page.
56+
57+
:type new_version: string
58+
:param new_version: New version being added.
59+
60+
:rtype: string
61+
:returns: Rendered versions page.
62+
"""
63+
versions = update_versions(new_version)
64+
65+
with open(VERSIONS_TMPL, 'r') as file_obj:
66+
page_template = file_obj.read()
67+
68+
versions_list = '\n'.join([LI_TEMPLATE % (version, version)
69+
for version in versions])
70+
71+
return page_template.format(versions=versions_list)
72+
73+
74+
def main():
75+
"""Creates new versions.html template."""
76+
new_version = get_distribution('google-cloud').version
77+
rendered = render_template(new_version)
78+
with open(VERSIONS_FILE, 'w') as file_obj:
79+
file_obj.write(rendered)
80+
81+
82+
if __name__ == '__main__':
83+
main()

scripts/versions.html.template

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<!DOCTYPE html>
2+
3+
<html xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
7+
<title>google-cloud-python Versions</title>
8+
9+
<link rel="stylesheet" href="_landing-page-static/css/docs-main.css" type="text/css" />
10+
<link rel="stylesheet" href="_landing-page-static/pygments.css" type="text/css" />
11+
<link rel="stylesheet" href="_landing-page-static/css/normalize.css" type="text/css" />
12+
13+
<script type="text/javascript" src="_landing-page-static/js/vendor/modernizr-2.6.2.min.js"></script>
14+
<link rel="shortcut icon" href="_landing-page-static/favicon.ico"/>
15+
<link rel="top" title="google-cloud-python Versions" href="#" />
16+
</head>
17+
<body>
18+
<header class="page-header fixed" role="banner">
19+
<h1 class="logo">
20+
<a href="index.html" title="back to home">
21+
<img src="_landing-page-static/images/logo.svg" alt="Google Cloud Platform" />
22+
<span class="google-cloud">google-cloud</span>
23+
</a>
24+
</h1>
25+
<nav class="main-nav">
26+
<div class="nav-current">Python</div>
27+
<ul class="menu">
28+
<li>
29+
<a href="
30+
https://googlecloudplatform.github.io/google-cloud-node" title="Node.js docs page">
31+
<img src="_landing-page-static/images/icon-lang-nodejs.svg" alt="Node.js icon" class="menu-icon" />
32+
Node.js
33+
</a>
34+
</li>
35+
<li>
36+
<a href="#" title="Python docs page">
37+
<img src="_landing-page-static/images/icon-lang-python-white.svg" alt="Python icon" class="menu-icon" />
38+
Python
39+
</a>
40+
</li>
41+
</ul>
42+
</nav><!-- end of .main-nav -->
43+
</header><!-- end of .page-header -->
44+
45+
<article class="main lang-page" role="main">
46+
47+
<header class="docs-header">
48+
<h1 class="page-title">Versions</h1>
49+
</header>
50+
51+
<section class="content">
52+
53+
<div class="toctree-wrapper compound">
54+
</div>
55+
<ul id="versions">
56+
{versions}
57+
</ul>
58+
59+
</section><!-- end of .content -->
60+
<nav class="side-nav">
61+
<ul><li><a href="stable/index.html">Documentation</a></li></ul>
62+
<ul class="simple">
63+
</ul>
64+
65+
<ul class="external-links">
66+
<li>
67+
<a href="https://github.com/GoogleCloudPlatform/google-cloud-python/" title="Python on Github">
68+
<img src="_landing-page-static/images/icon-link-github.svg" alt="Github icon" />
69+
Github
70+
</a>
71+
</li>
72+
<li>
73+
<a href="https://github.com/GoogleCloudPlatform/google-cloud-python/issues" title="Python issues on Github">
74+
<img src="_landing-page-static/images/icon-link-github.svg" alt="Github icon" />
75+
Issues
76+
</a>
77+
</li>
78+
<li>
79+
<a href="http://stackoverflow.com/questions/tagged/google-cloud-python" title="google-cloud on StackOverflow">
80+
<img src="_landing-page-static/images/icon-link-stackoverflow.svg" alt="StackOverflow icon" />
81+
google-cloud
82+
</a>
83+
</li>
84+
<li>
85+
<a href="https://pypi.python.org/pypi/google-cloud" title="Python package manager">
86+
<img src="_landing-page-static/images/icon-link-package-manager.svg" alt="Package Manager icon" />
87+
Package Manager
88+
</a>
89+
</li>
90+
</ul>
91+
</nav><!-- end of .side-nav -->
92+
</article><!-- end of .main -->
93+
94+
<script src="_landing-page-static/js/vendor/jquery-1.10.2.min.js"></script>
95+
<script src="_landing-page-static/js/plugins.js"></script>
96+
<script src="_landing-page-static/js/main.js"></script>
97+
98+
</body>
99+
</html>

0 commit comments

Comments
 (0)