Skip to content

Commit

Permalink
Package docs files for simple deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Jul 29, 2016
1 parent c0e4e37 commit c635c29
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 11 deletions.
130 changes: 130 additions & 0 deletions docs/json/json/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<section class="hero-banner">
<div class="container clearfix">
<div class="quote-box">
<h1>gcloud-python</h1>
<p>Google Cloud Client Library for Python
- an idiomatic, intuitive, and natural way for Python developers to
integrate with Google Cloud Platform services, like Cloud Datastore
and Cloud Storage.</p>
</div>

<div class="quote-box--supplementary">
<pre class="skip-highlight"><code class="subtle--blue">$</code> pip install <code class="subtle--blue">--upgrade</code> <strong>gcloud</strong></pre>
<h4 class="latest-release subtle" ng-if="home.latestRelease">
Latest Release <a ng-href="{{home.latestRelease.link}}" class="latest-release--link white">{{home.latestRelease.name}}</a>
{{home.latestRelease.date|date}}
</h4>
</div>
</div><!-- end of .container -->
</section><!-- end of .hero-banner -->

<section class="block featuring">
<div class="container">
<ul class="featuring-links">
<li>
<a href="#/docs/{{home.latestRelease.name}}/gcloud" title="gcloud-python docs" class="btn btn-docs">
<img src="src/images/icon-lang-python-gray.svg" alt="Python icon" />
Read the Docs
</a>
</li>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python" title="gcloud-python on GitHub" class="ext-link">
<img src="src/images/icon-link-github.svg" alt="GitHub icon" />
GitHub
</a>
</li>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python/issues" title="gcloud-python issues on Github" class="ext-link">
<img src="src/images/icon-link-github.svg" alt="GitHub icon" />
Issues
</a>
</li>
<li>
<a href="http://stackoverflow.com/questions/tagged/gcloud-python" title="gcloud-python on StackOverflow" class="ext-link">
<img src="src/images/icon-link-stackoverflow.svg" alt="StackOverflow icon" />
StackOverflow
</a>
</li>
<li>
<a href="https://pypi.python.org/pypi/gcloud" title="gcloud-python on pypi" class="ext-link">
<img src="src/images/icon-link-package-manager.svg" alt="pypi icon" />
PyPI
</a>
</li>
</ul>
</div><!-- end of .container -->
</section><!-- end of .featuring -->

<section class="block about">
<div class="container clearfix">
<div class="quote-box">
<h3 class="block-title">What is it?</h3>

<p><code>gcloud-python</code> is a client library for accessing Google
Cloud Platform services that significantly reduces the boilerplate
code you have to write. The library provides high-level API
abstractions so they're easier to understand. It embraces
idioms of Python, works well with the standard library, and
integrates better with your codebase.
All this means you spend more time creating code that matters
to you.</p>

<p><code>gcloud-python</code> is configured to access Google Cloud Platform
services and authorize (OAuth 2.0) automatically on your behalf.
With a one-line install and a private key, you are up and ready
to go. Better yet, if you are running on a Google Compute Engine
instance, the one-line install is enough!</p>

</div>

<div class="quote-box--supplementary">
<h4>Retrieve Datastore Entities</h4>

<div hljs hlsj-language="python">
from gcloud import datastore

client = datastore.Client()
product_key = client.key('Product', 123)
print(client.get(product_key))
</div>
</div>
</div><!-- end of .container -->
</section><!-- end of .featuring -->

<section class="block examples">
<div class="container clearfix">
<h3 class="block-title">Examples</h3>

<ul>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python-expenses-demo"><code>gcloud-python-expenses-demo</code></a> - Use gcloud-python with the Datastore and Cloud Storage to manage expenses
</li>
</ul>
</div>
</section>

<section class="block">
<div class="container clearfix">
<h3 class="block-title">FAQ</h3>

<h4>What is the relationship between the <code>gcloud-python</code> package
and the <code>gcloud</code> command-line tool?</h4>
<p>Both the <code>gcloud</code> command-line tool and
<code>gcloud-python</code> package are a part of the Google Cloud SDK: a collection
of tools and libraries that enable you to easily create and manage
resources on the Google Cloud Platform. The <code>gcloud</code> command-line
tool can be used to manage both your development workflow and your
Google Cloud Platform resources while the <code>gcloud-python</code> package is the
Google Cloud Client Library for Python.</p>

<h4>What is the relationship between <code>gcloud-python</code>
and the Google APIs Python Client?</h4>
<p>The <a href="https://github.com/google/google-api-python-client">
Google APIs Python Client</a> is a client library for
using the broad set of Google APIs.
<code>gcloud-python</code> is built specifically for the Google Cloud Platform
and is the recommended way to integrate Google Cloud APIs into your
Python applications. If your application requires both Google Cloud Platform and
other Google APIs, the 2 libraries may be used by your application.</p>
</div>
</section> <!-- end of FAQ -->
130 changes: 130 additions & 0 deletions docs/json/json/master/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<section class="hero-banner">
<div class="container clearfix">
<div class="quote-box">
<h1>gcloud-python</h1>
<p>Google Cloud Client Library for Python
- an idiomatic, intuitive, and natural way for Python developers to
integrate with Google Cloud Platform services, like Cloud Datastore
and Cloud Storage.</p>
</div>

<div class="quote-box--supplementary">
<pre class="skip-highlight"><code class="subtle--blue">$</code> pip install <code class="subtle--blue">--upgrade</code> <strong>gcloud</strong></pre>
<h4 class="latest-release subtle" ng-if="home.latestRelease">
Latest Release <a ng-href="{{home.latestRelease.link}}" class="latest-release--link white">{{home.latestRelease.name}}</a>
{{home.latestRelease.date|date}}
</h4>
</div>
</div><!-- end of .container -->
</section><!-- end of .hero-banner -->

<section class="block featuring">
<div class="container">
<ul class="featuring-links">
<li>
<a href="#/docs/{{home.latestRelease.name}}/gcloud" title="gcloud-python docs" class="btn btn-docs">
<img src="src/images/icon-lang-python-gray.svg" alt="Python icon" />
Read the Docs
</a>
</li>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python" title="gcloud-python on GitHub" class="ext-link">
<img src="src/images/icon-link-github.svg" alt="GitHub icon" />
GitHub
</a>
</li>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python/issues" title="gcloud-python issues on Github" class="ext-link">
<img src="src/images/icon-link-github.svg" alt="GitHub icon" />
Issues
</a>
</li>
<li>
<a href="http://stackoverflow.com/questions/tagged/gcloud-python" title="gcloud-python on StackOverflow" class="ext-link">
<img src="src/images/icon-link-stackoverflow.svg" alt="StackOverflow icon" />
StackOverflow
</a>
</li>
<li>
<a href="https://pypi.python.org/pypi/gcloud" title="gcloud-python on pypi" class="ext-link">
<img src="src/images/icon-link-package-manager.svg" alt="pypi icon" />
PyPI
</a>
</li>
</ul>
</div><!-- end of .container -->
</section><!-- end of .featuring -->

<section class="block about">
<div class="container clearfix">
<div class="quote-box">
<h3 class="block-title">What is it?</h3>

<p><code>gcloud-python</code> is a client library for accessing Google
Cloud Platform services that significantly reduces the boilerplate
code you have to write. The library provides high-level API
abstractions so they're easier to understand. It embraces
idioms of Python, works well with the standard library, and
integrates better with your codebase.
All this means you spend more time creating code that matters
to you.</p>

<p><code>gcloud-python</code> is configured to access Google Cloud Platform
services and authorize (OAuth 2.0) automatically on your behalf.
With a one-line install and a private key, you are up and ready
to go. Better yet, if you are running on a Google Compute Engine
instance, the one-line install is enough!</p>

</div>

<div class="quote-box--supplementary">
<h4>Retrieve Datastore Entities</h4>

<div hljs hlsj-language="python">
from gcloud import datastore

client = datastore.Client()
product_key = client.key('Product', 123)
print(client.get(product_key))
</div>
</div>
</div><!-- end of .container -->
</section><!-- end of .featuring -->

<section class="block examples">
<div class="container clearfix">
<h3 class="block-title">Examples</h3>

<ul>
<li>
<a href="https://github.com/GoogleCloudPlatform/gcloud-python-expenses-demo"><code>gcloud-python-expenses-demo</code></a> - Use gcloud-python with the Datastore and Cloud Storage to manage expenses
</li>
</ul>
</div>
</section>

<section class="block">
<div class="container clearfix">
<h3 class="block-title">FAQ</h3>

<h4>What is the relationship between the <code>gcloud-python</code> package
and the <code>gcloud</code> command-line tool?</h4>
<p>Both the <code>gcloud</code> command-line tool and
<code>gcloud-python</code> package are a part of the Google Cloud SDK: a collection
of tools and libraries that enable you to easily create and manage
resources on the Google Cloud Platform. The <code>gcloud</code> command-line
tool can be used to manage both your development workflow and your
Google Cloud Platform resources while the <code>gcloud-python</code> package is the
Google Cloud Client Library for Python.</p>

<h4>What is the relationship between <code>gcloud-python</code>
and the Google APIs Python Client?</h4>
<p>The <a href="https://github.com/google/google-api-python-client">
Google APIs Python Client</a> is a client library for
using the broad set of Google APIs.
<code>gcloud-python</code> is built specifically for the Google Cloud Platform
and is the recommended way to integrate Google Cloud APIs into your
Python applications. If your application requires both Google Cloud Platform and
other Google APIs, the 2 libraries may be used by your application.</p>
</div>
</section> <!-- end of FAQ -->
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/json/toc.json → docs/json/json/master/toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"title": "Dataset"
},
{
"type": "gcloud/bigquery/job/job",
"type": "gcloud/bigquery/job",
"title": "Jobs"
},
{
Expand Down
43 changes: 41 additions & 2 deletions scripts/generate_json_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import inspect
import json
import os
import shutil
import types

import pdoc
Expand Down Expand Up @@ -536,6 +537,40 @@ def get_snippet_examples(module, json_docs_dir):
return snippets


def package_files(generated_json_dir, docs_build_dir, static_json_dir,
tag='master'):
"""Copy app and JSON files into a convenient place to deploy from.
Structure needs to be...
root
- src/
- images/
- app.js
- app.css
- vendor.js
- vendor.css
- json/
- master/
- toc.json
- types.json
- home.html
- index.json
- overview.html
- home.html
- home.html
- index.html
- manifest.json
"""
package_path = os.path.join(docs_build_dir, 'json_build')
shutil.rmtree(package_path, ignore_errors=True)

shutil.copytree(static_json_dir, package_path)
shutil.copytree(os.path.join(generated_json_dir, 'gcloud'),
os.path.join(package_path, 'json', tag, 'gcloud'))
shutil.copyfile(os.path.join(generated_json_dir, 'types.json'),
os.path.join(package_path, 'json', tag, 'types.json'))


def main():
parser = argparse.ArgumentParser(description='Document Python modules.')
parser.add_argument('--tag', help='The version of the documentation.',
Expand All @@ -559,6 +594,7 @@ def main():
'dns': [],
'error_reporting': [],
'environment_vars': [],
'error_reporting': [],
'exceptions': [],
'iterator': [],
'logging': [],
Expand All @@ -572,7 +608,10 @@ def main():
}

BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
JSON_DOCS_DIR = os.path.join(BASE_DIR, 'docs', '_build', 'json', args.tag)
BASE_JSON_DOCS_DIR = os.path.join(BASE_DIR, 'docs', 'json')

DOCS_BUILD_DIR = os.path.join(BASE_DIR, 'docs', '_build')
JSON_DOCS_DIR = os.path.join(DOCS_BUILD_DIR, 'json', args.tag)
LIB_DIR = os.path.abspath(args.basepath)

library_dir = os.path.join(LIB_DIR, 'gcloud')
Expand All @@ -581,7 +620,7 @@ def main():
generate_module_docs(public_mods, JSON_DOCS_DIR, BASE_DIR, toc)
generate_doc_types_json(public_mods,
os.path.join(JSON_DOCS_DIR, 'types.json'))

package_files(JSON_DOCS_DIR, DOCS_BUILD_DIR, BASE_JSON_DOCS_DIR)
if args.show_toc:
print json.dumps(toc, indent=4)

Expand Down
9 changes: 1 addition & 8 deletions scripts/update_json_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ function pushDocs () {
git submodule add -f -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} ghpages
fi
mkdir -p ghpages/json/${1}
cp -R docs/_build/json/${1}/* ghpages/json/${1}
cp docs/json/toc.json ghpages/json/${1}
cp docs/json/index.json ghpages/json/${1}
cp docs/json/overview.html ghpages/json/${1}
cp docs/json/home.html ghpages/json/
cp -R docs/json/src ghpages
cp docs/json/manifest.json ghpages
cp docs/json/index.html ghpages
cp -R docs/_build/json_build/* ghpages/
cd ghpages
git add .
if [[ -n "$(git status --porcelain)" ]]; then
Expand Down

0 comments on commit c635c29

Please sign in to comment.