Skip to content

Commit 5fc0150

Browse files
committed
Merge pull request #1345 from dhermes/some-docs-cleanup
Fixing some docstrings that did not render as intended
2 parents 02c645f + c684c29 commit 5fc0150

10 files changed

Lines changed: 81 additions & 52 deletions

File tree

File renamed without changes.

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
dns-usage
6868
Client <dns-client>
6969
dns-zone
70-
dns-resource_record_set
70+
dns-resource-record-set
7171
dns-changes
7272

7373
.. toctree::
@@ -115,7 +115,7 @@ try installing the ``dev`` packages beforehand:
115115
116116
$ sudo apt-get install python-dev libssl-dev
117117
118-
If you want to install `gcloud-python` from source,
118+
If you want to install ``gcloud-python`` from source,
119119
you can clone the repository from GitHub:
120120

121121
.. code-block:: console

gcloud/bigquery/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,15 @@ def list_jobs(self, max_results=None, page_token=None, all_users=None,
151151
152152
:type state_filter: string
153153
:param state_filter: if passed, include only jobs matching the given
154-
state. One of "done", "pending", or "running".
154+
state. One of
155+
156+
* ``"done"``
157+
* ``"pending"``
158+
* ``"running"``
155159
156160
:rtype: tuple, (list, str)
157161
:returns: list of job instances, plus a "next page token" string:
158-
if the token is not None, indicates that more jobs can be
162+
if the token is not ``None``, indicates that more jobs can be
159163
retrieved with another call, passing that value as
160164
``page_token``).
161165
"""

gcloud/bigquery/dataset.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@
2323
class AccessGrant(object):
2424
"""Represent grant of an access role to an entity.
2525
26-
:type role: string (one of 'OWNER', 'WRITER', 'READER').
27-
:param role: role granted to the entity.
26+
:type role: string
27+
:param role: Role granted to the entity. One of
2828
29-
:type entity_type: string (one of 'specialGroup', 'groupByEmail', or
30-
'userByEmail')
31-
:param entity_type: type of entity being granted the role.
29+
* ``'OWNER'``
30+
* ``'WRITER'``
31+
* ``'READER'``
32+
33+
:type entity_type: string
34+
:param entity_type: Type of entity being granted the role. One of
35+
36+
* ``'specialGroup'``
37+
* ``'groupByEmail'``
38+
* ``'userByEmail'``
3239
3340
:type entity_id: string
3441
:param entity_id: ID of entity being granted the role.
@@ -360,7 +367,7 @@ def create(self, client=None):
360367
"""API call: create the dataset via a PUT request
361368
362369
See:
363-
https://cloud.google.com/bigquery/reference/rest/v2/tables/insert
370+
https://cloud.google.com/bigquery/docs/reference/v2/tables/insert
364371
365372
:type client: :class:`gcloud.bigquery.client.Client` or ``NoneType``
366373
:param client: the client to use. If not passed, falls back to the
@@ -465,7 +472,7 @@ def delete(self, client=None):
465472
"""API call: delete the dataset via a DELETE request
466473
467474
See:
468-
https://cloud.google.com/bigquery/reference/rest/v2/datasets/delete
475+
https://cloud.google.com/bigquery/docs/reference/v2/tables/delete
469476
470477
:type client: :class:`gcloud.bigquery.client.Client` or ``NoneType``
471478
:param client: the client to use. If not passed, falls back to the
@@ -491,7 +498,7 @@ def list_tables(self, max_results=None, page_token=None):
491498
492499
:rtype: tuple, (list, str)
493500
:returns: list of :class:`gcloud.bigquery.table.Table`, plus a
494-
"next page token" string: if not None, indicates that
501+
"next page token" string: if not ``None``, indicates that
495502
more tables can be retrieved with another call (pass that
496503
value as ``page_token``).
497504
"""

gcloud/bigtable/table.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ def delete(self):
192192
def list_column_families(self):
193193
"""List the column families owned by this table.
194194
195-
:rtype: dictionary with string as keys and
196-
:class:`.column_family.ColumnFamily` as values
197-
:returns: List of column families attached to this table.
195+
:rtype: dict
196+
:returns: Dictionary of column families attached to this table. Keys
197+
are strings (column family names) and values are
198+
:class:`.column_family.ColumnFamily` instances.
198199
:raises: :class:`ValueError <exceptions.ValueError>` if the column
199200
family name from the response does not agree with the computed
200201
name from the column family ID.

gcloud/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def from_service_account_json(cls, json_credentials_path, *args, **kwargs):
4646
:type args: tuple
4747
:param args: Remaining positional arguments to pass to constructor.
4848
49-
:type kwargs: dictionary
49+
:type kwargs: dict
5050
:param kwargs: Remaining keyword arguments to pass to constructor.
5151
5252
:rtype: :class:`gcloud.pubsub.client.Client`
5353
:returns: The client created with the retrieved JSON credentials.
54-
:raises: class:`TypeError` if there is a conflict with the kwargs
54+
:raises: :class:`TypeError` if there is a conflict with the kwargs
5555
and the credentials created by the factory.
5656
"""
5757
if 'credentials' in kwargs:
@@ -80,12 +80,12 @@ def from_service_account_p12(cls, client_email, private_key_path,
8080
:type args: tuple
8181
:param args: Remaining positional arguments to pass to constructor.
8282
83-
:type kwargs: dictionary
83+
:type kwargs: dict
8484
:param kwargs: Remaining keyword arguments to pass to constructor.
8585
8686
:rtype: :class:`gcloud.client.Client`
8787
:returns: The client created with the retrieved P12 credentials.
88-
:raises: class:`TypeError` if there is a conflict with the kwargs
88+
:raises: :class:`TypeError` if there is a conflict with the kwargs
8989
and the credentials created by the factory.
9090
"""
9191
if 'credentials' in kwargs:

gcloud/connection.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,18 @@ class JSONConnection(Connection):
124124
"""A connection to a Google JSON-based API.
125125
126126
These APIs are discovery based. For reference:
127+
127128
https://developers.google.com/discovery/
128129
129-
This defines :meth:`Connection.api_request` for making a generic JSON
130+
This defines :meth:`api_request` for making a generic JSON
130131
API request and API requests are created elsewhere.
131132
132133
The class constants
133-
* ``API_BASE_URL``
134-
* ``API_VERSION``
135-
* ``API_URL_TEMPLATE``
134+
135+
* :attr:`API_BASE_URL`
136+
* :attr:`API_VERSION`
137+
* :attr:`API_URL_TEMPLATE`
138+
136139
must be updated by subclasses.
137140
"""
138141

@@ -303,12 +306,12 @@ def api_request(self, method, path, query_params=None,
303306
latest API version supported by
304307
gcloud-python.
305308
306-
:type expect_json: boolean
309+
:type expect_json: bool
307310
:param expect_json: If True, this method will try to parse the
308311
response as JSON and raise an exception if
309312
that cannot be done. Default is True.
310313
311-
:type _target_object: object or :class:`NoneType`
314+
:type _target_object: :class:`object` or :class:`NoneType`
312315
:param _target_object: Protected argument to be used by library
313316
callers. This can allow custom behavior, for
314317
example, to defer an HTTP request and complete

gcloud/credentials.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,51 @@ def get_credentials():
4646
"""Gets credentials implicitly from the current environment.
4747
4848
.. note::
49-
You should not need to use this function directly. Instead, use the
50-
helper method :func:`gcloud.datastore.__init__.get_connection`
51-
which uses this method under the hood.
49+
50+
You should not need to use this function directly. Instead, use a
51+
helper method which uses this method under the hood.
5252
5353
Checks environment in order of precedence:
5454
5555
* Google App Engine (production and testing)
56-
* Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
56+
* Environment variable :envvar:`GOOGLE_APPLICATION_CREDENTIALS` pointing to
5757
a file with stored credentials information.
5858
* Stored "well known" file associated with ``gcloud`` command line tool.
5959
* Google Compute Engine production environment.
6060
61-
The file referred to in GOOGLE_APPLICATION_CREDENTIALS is expected to
62-
contain information about credentials that are ready to use. This means
63-
either service account information or user account information with
64-
a ready-to-use refresh token::
61+
The file referred to in :envvar:`GOOGLE_APPLICATION_CREDENTIALS` is
62+
expected to contain information about credentials that are ready to use.
63+
This means either service account information or user account information
64+
with a ready-to-use refresh token:
65+
66+
.. code:: json
67+
68+
{
69+
'type': 'authorized_user',
70+
'client_id': '...',
71+
'client_secret': '...',
72+
'refresh_token': '...'
73+
}
6574
66-
{ {
67-
'type': 'authorized_user', 'type': 'service_account',
68-
'client_id': '...', 'client_id': '...',
69-
'client_secret': '...', OR 'client_email': '...',
70-
'refresh_token': '..., 'private_key_id': '...',
71-
} 'private_key': '...',
72-
}
75+
or
76+
77+
.. code:: json
78+
79+
{
80+
'type': 'service_account',
81+
'client_id': '...',
82+
'client_email': '...',
83+
'private_key_id': '...',
84+
'private_key': '...'
85+
}
7386
7487
The second of these is simply a JSON key downloaded from the Google APIs
7588
console. The first is a close cousin of the "client secrets" JSON file
76-
used by ``oauth2client.clientsecrets`` but differs in formatting.
89+
used by :mod:`oauth2client.clientsecrets` but differs in formatting.
7790
7891
:rtype: :class:`oauth2client.client.GoogleCredentials`,
79-
:class:`oauth2client.appengine.AppAssertionCredentials`,
80-
:class:`oauth2client.gce.AppAssertionCredentials`,
92+
:class:`oauth2client.contrib.appengine.AppAssertionCredentials`,
93+
:class:`oauth2client.contrib.gce.AppAssertionCredentials`,
8194
:class:`oauth2client.service_account._ServiceAccountCredentials`
8295
:returns: A new credentials instance corresponding to the implicit
8396
environment.
@@ -119,7 +132,7 @@ def get_for_service_account_p12(client_email, private_key_path, scope=None):
119132
120133
.. note::
121134
This method is not used by default, instead :func:`get_credentials`
122-
is used. This method is intended to be used when the environments is
135+
is used. This method is intended to be used when the environment is
123136
known explicitly and detecting the environment implicitly would be
124137
superfluous.
125138
@@ -302,7 +315,8 @@ def generate_signed_url(credentials, resource, expiration,
302315
:param resource: A pointer to a specific resource
303316
(typically, ``/bucket-name/path/to/blob.txt``).
304317
305-
:type expiration: int, long, datetime.datetime, datetime.timedelta
318+
:type expiration: :class:`int`, :class:`long`, :class:`datetime.datetime`,
319+
:class:`datetime.timedelta`
306320
:param expiration: When the signed URL should expire.
307321
308322
:type api_access_endpoint: string

gcloud/exceptions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Custom exceptions for gcloud.storage package.
15+
"""Custom exceptions for :mod:`gcloud` package.
1616
1717
See: https://cloud.google.com/storage/docs/json_api/v1/status-codes
1818
"""
@@ -171,7 +171,7 @@ def make_exception(response, content, error_info=None, use_json=True):
171171
:param error_info: Optional string giving extra information about the
172172
failed request.
173173
174-
:type use_json: boolean
174+
:type use_json: bool
175175
:param use_json: Flag indicating if ``content`` is expected to be JSON.
176176
177177
:rtype: instance of :class:`GCloudError`, or a concrete subclass.
@@ -213,7 +213,7 @@ def _walk_subclasses(klass):
213213

214214

215215
# Build the code->exception class mapping.
216-
for eklass in _walk_subclasses(GCloudError):
217-
code = getattr(eklass, 'code', None)
216+
for _eklass in _walk_subclasses(GCloudError):
217+
code = getattr(_eklass, 'code', None)
218218
if code is not None:
219-
_HTTP_CODE_TO_EXCEPTION[code] = eklass
219+
_HTTP_CODE_TO_EXCEPTION[code] = _eklass

scripts/run_pylint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def valid_filename(filename):
104104
def is_production_filename(filename):
105105
"""Checks if the file contains production code.
106106
107-
:rtype: boolean
107+
:rtype: bool
108108
:returns: Boolean indicating production status.
109109
"""
110110
return not ('demo' in filename or 'test' in filename)
@@ -127,7 +127,7 @@ def get_files_for_linting(allow_limited=True):
127127
``GCLOUD_REMOTE_FOR_LINT`` and ``GCLOUD_BRANCH_FOR_LINT`` can be set to
128128
specify a remote branch to diff against.
129129
130-
:type allow_limited: boolean
130+
:type allow_limited: bool
131131
:param allow_limited: Boolean indicating if a reduced set of files can
132132
be used.
133133

0 commit comments

Comments
 (0)