Skip to content

Commit f898953

Browse files
committed
Merge pull request #206 from dhermes/tox-docstring-fix
Sphinx and PEP8 docstring fix
2 parents 753b342 + 39101ae commit f898953

File tree

9 files changed

+42
-26
lines changed

9 files changed

+42
-26
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
# List of patterns, relative to source directory, that match files and
7171
# directories to ignore when looking for source files.
72-
exclude_patterns = ['_build']
72+
exclude_patterns = ['_build', '_components/*']
7373

7474
# The reST default role (used for this markup: `text`) to use for all documents.
7575
#default_role = None

docs/index.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
.. toctree::
44
:hidden:
55

6+
common-api
67
datastore-api
8+
datastore-getting-started
9+
datastore-quickstart
10+
getting-started
711
storage-api
8-
common-api
12+
storage-getting-started
13+
storage-quickstart
14+
915

1016
Google Cloud Python API
1117
=======================

gcloud/datastore/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def get_connection(client_email, private_key_path):
7171

7272

7373
def get_dataset(dataset_id, client_email, private_key_path):
74-
"""Shortcut method to establish a connection to a particular dataset in the Cloud Datastore.
74+
"""Establish a connection to a particular dataset in the Cloud Datastore.
75+
76+
This is a shortcut method for creating a connection and using it
77+
to connect to a dataset.
7578
7679
You'll generally use this as the first call to working with the API:
7780

gcloud/datastore/entity.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, dataset=None, kind=None):
7070
self._key = None
7171

7272
def dataset(self):
73-
"""Get the :class:`gcloud.datastore.dataset.Dataset` in which this entity belongs.
73+
"""Get the :class:`.dataset.Dataset` in which this entity belongs.
7474
7575
:rtype: :class:`gcloud.datastore.dataset.Dataset`
7676
:returns: The Dataset containing the entity if there is a key,
@@ -86,7 +86,7 @@ def dataset(self):
8686
return self.key().dataset()
8787

8888
def key(self, key=None):
89-
"""Get or set the :class:`gcloud.datastore.key.Key` on the current entity.
89+
"""Get or set the :class:`.datastore.key.Key` on the current entity.
9090
9191
:type key: :class:`glcouddatastore.key.Key`
9292
:param key: The key you want to set on the entity.
@@ -122,7 +122,10 @@ def kind(self):
122122

123123
@classmethod
124124
def from_key(cls, key):
125-
"""Factory method for creating an entity based on the :class:`gcloud.datastore.key.Key`.
125+
"""Create entity based on :class:`.datastore.key.Key`.
126+
127+
.. note::
128+
This is a factory method.
126129
127130
:type key: :class:`gcloud.datastore.key.Key`
128131
:param key: The key for the entity.

gcloud/datastore/key.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class Key(object):
99
"""
1010
An immutable representation of a datastore Key.
11+
12+
.. automethod:: __init__
1113
"""
1214

1315
def __init__(self, dataset=None, namespace=None, path=None):
@@ -52,7 +54,7 @@ def from_protobuf(cls, pb, dataset=None):
5254
5355
:type dataset: :class:`gcloud.datastore.dataset.Dataset`
5456
:param dataset: A dataset instance. If not passed, defaults to an
55-
instance whose ID is derived from pb.
57+
instance whose ID is derived from pb.
5658
5759
:rtype: :class:`gcloud.datastore.key.Key`
5860
:returns: a new `Key` instance
@@ -116,17 +118,18 @@ def to_protobuf(self):
116118
def from_path(cls, *args, **kwargs):
117119
"""Factory method for creating a key based on a path.
118120
119-
:type args: :class:`tuple
120-
:param args: sequence of even length, where the first of each
121-
pair is a string representing the 'kind' of the path element, and the
122-
second of the pair is either a string (for the path element's name)
123-
or an integer (for its id).
121+
:type args: :class:`tuple`
122+
:param args: sequence of even length, where the first of each pair is a
123+
string representing the 'kind' of the path element, and the
124+
second of the pair is either a string (for the path
125+
element's name) or an integer (for its id).
124126
125127
:type kwargs: :class:`dict`
126-
:param kwargs: Other named parameters which can be passed to `__init__()`.
128+
:param kwargs: Other named parameters which can be passed to
129+
:func:`Key.__init__`.
127130
128131
:rtype: :class:`gcloud.datastore.key.Key`
129-
:returns: a new `Key` instance
132+
:returns: a new :class:`Key` instance
130133
"""
131134
if len(args) % 2:
132135
raise ValueError('Must pass an even number of args.')
@@ -150,7 +153,7 @@ def is_partial(self):
150153
151154
:rtype: :class:`bool`
152155
:returns: True if the last element of the key's path does not have an 'id'
153-
or a 'name'.
156+
or a 'name'.
154157
"""
155158
return (self.id_or_name() is None)
156159

@@ -194,11 +197,11 @@ def path(self, path=None):
194197
195198
:type path: sequence of dicts
196199
:param path: Each dict must have keys 'kind' (a string) and optionally
197-
'name' (a string) or 'id' (an integer).
200+
'name' (a string) or 'id' (an integer).
198201
199202
:rtype: :class:`Key` (for setter); or :class:`str` (for getter)
200203
:returns: a new key, cloned from self., with the given path (setter);
201-
or self's path (getter).
204+
or self's path (getter).
202205
"""
203206
if path:
204207
clone = self._clone()
@@ -263,7 +266,7 @@ def id_or_name(self):
263266
264267
:rtype: :class:`int` (if 'id' is set); or :class:`str` (the 'name')
265268
:returns: True if the last element of the key's path has either an 'id'
266-
or a 'name'.
269+
or a 'name'.
267270
"""
268271
return self.id() or self.name()
269272

@@ -272,7 +275,8 @@ def parent(self): # pragma NO COVER
272275
273276
:rtype: :class:`gcloud.datastore.key.Key`
274277
:returns: a new `Key` instance, whose path consists of all but the last
275-
element of self's path. If self has only one path element, return None.
278+
element of self's path. If self has only one path element,
279+
return None.
276280
"""
277281
if len(self._path) <= 1:
278282
return None

gcloud/datastore/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def _clone(self):
6363
return clone
6464

6565
def to_protobuf(self):
66-
"""Convert the :class:`Query` instance to a :class:`gcloud.datastore.datastore_v1_pb2.Query`.
66+
"""Convert :class:`Query` instance to :class:`.datastore_v1_pb2.Query`.
6767
68-
:rtype: :class:`gclouddatstore.datastore_v1_pb2.Query`
68+
:rtype: :class:`gcloud.datastore.datastore_v1_pb2.Query`
6969
:returns: A Query protobuf that can be sent to the protobuf API.
7070
"""
7171
return self._pb
@@ -148,7 +148,7 @@ def ancestor(self, ancestor):
148148
>>> query = dataset.query('Person')
149149
>>> filtered_query = query.ancestor(['Person', '1'])
150150
151-
Each call to ``.ancestor()`` returns a cloned :class:`Query:,
151+
Each call to ``.ancestor()`` returns a cloned :class:`Query`,
152152
however a query may only have one ancestor at a time.
153153
154154
:type ancestor: :class:`gcloud.datastore.key.Key` or list

gcloud/storage/acl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def save(self):
379379

380380

381381
class DefaultObjectACL(BucketACL):
382-
"""A subclass of BucketACL representing the default object ACL for a bucket."""
382+
"""A class representing the default object ACL for a bucket."""
383383

384384
def save(self):
385385
"""Save this ACL as the default object ACL for the current bucket."""

gcloud/storage/bucket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def get_all_keys(self):
104104
return list(self)
105105

106106
def new_key(self, key):
107-
"""Given a path name (or a Key), return a :class:`gcloud.storage.key.Key` object.
107+
"""Given a path name (or Key), return a :class:`.storage.key.Key` object.
108108
109109
This is really useful when you're not sure
110110
if you have a Key object or a string path name.

gcloud/storage/iterator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def __init__(self, connection):
146146
super(BucketIterator, self).__init__(connection=connection, path='/b')
147147

148148
def get_items_from_response(self, response):
149-
"""Factory method which yields :class:`gcloud.storage.bucket.Bucket` items from a response.
149+
"""Factory method which yields :class:`.Bucket` items from a response.
150150
151151
:type response: dict
152152
:param response: The JSON API response for a page of buckets.
@@ -174,7 +174,7 @@ def __init__(self, bucket):
174174
connection=bucket.connection, path=bucket.path + '/o')
175175

176176
def get_items_from_response(self, response):
177-
"""Factory method which yields :class:`gcloud.storage.key.Key` items from a response.
177+
"""Factory method, yields :class:`.storage.key.Key` items from response.
178178
179179
:type response: dict
180180
:param response: The JSON API response for a page of keys.

0 commit comments

Comments
 (0)