Skip to content

Commit dc5215c

Browse files
Gurov Ilyatswast
authored andcommitted
refactor(bigquery): rewrite docs in Google style, part 1 (googleapis#9326)
towards issue googleapis#9092
1 parent 1d4a547 commit dc5215c

10 files changed

Lines changed: 189 additions & 237 deletions

File tree

bigquery/google/cloud/bigquery/_http.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
class Connection(_http.JSONConnection):
2323
"""A connection to Google BigQuery via the JSON REST API.
2424
25-
:type client: :class:`~google.cloud.bigquery.client.Client`
26-
:param client: The client that owns the current connection.
25+
Args:
26+
client (google.cloud.bigquery.client.Client): The client that owns the current connection.
2727
28-
:type client_info: :class:`~google.api_core.client_info.ClientInfo`
29-
:param client_info: (Optional) instance used to generate user agent.
28+
client_info (google.api_core.client_info.ClientInfo): (Optional) instance used to generate user agent.
3029
"""
3130

3231
DEFAULT_API_ENDPOINT = "https://bigquery.googleapis.com"

bigquery/google/cloud/bigquery/dataset.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ class Dataset(object):
349349
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets
350350
351351
Args:
352-
dataset_ref (Union[ \
353-
:class:`~google.cloud.bigquery.dataset.DatasetReference`, \
354-
str, \
355-
]):
352+
dataset_ref (Union[google.cloud.bigquery.dataset.DatasetReference, str]):
356353
A pointer to a dataset. If ``dataset_ref`` is a string, it must
357354
include both the project ID and the dataset ID, separated by
358355
``.``.

bigquery/google/cloud/bigquery/dbapi/connection.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
class Connection(object):
2222
"""DB-API Connection to Google BigQuery.
2323
24-
:type client: :class:`~google.cloud.bigquery.Client`
25-
:param client: A client used to connect to BigQuery.
24+
Args:
25+
client (google.cloud.bigquery.Client): A client used to connect to BigQuery.
2626
"""
2727

2828
def __init__(self, client):
@@ -37,22 +37,22 @@ def commit(self):
3737
def cursor(self):
3838
"""Return a new cursor object.
3939
40-
:rtype: :class:`~google.cloud.bigquery.dbapi.Cursor`
41-
:returns: A DB-API cursor that uses this connection.
40+
Returns:
41+
google.cloud.bigquery.dbapi.Cursor: A DB-API cursor that uses this connection.
4242
"""
4343
return cursor.Cursor(self)
4444

4545

4646
def connect(client=None):
4747
"""Construct a DB-API connection to Google BigQuery.
4848
49-
:type client: :class:`~google.cloud.bigquery.Client`
50-
:param client:
51-
(Optional) A client used to connect to BigQuery. If not passed, a
52-
client is created using default options inferred from the environment.
49+
Args:
50+
client (google.cloud.bigquery.Client):
51+
(Optional) A client used to connect to BigQuery. If not passed, a
52+
client is created using default options inferred from the environment.
5353
54-
:rtype: :class:`~google.cloud.bigquery.dbapi.Connection`
55-
:returns: A new DB-API connection to BigQuery.
54+
Returns:
55+
google.cloud.bigquery.dbapi.Connection: A new DB-API connection to BigQuery.
5656
"""
5757
if client is None:
5858
client = bigquery.Client()

bigquery/google/cloud/bigquery/dbapi/types.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,27 @@
3333
def Binary(string):
3434
"""Contruct a DB-API binary value.
3535
36-
:type string: str
37-
:param string: A string to encode as a binary value.
36+
Args:
37+
string (str): A string to encode as a binary value.
3838
39-
:rtype: bytes
40-
:returns: The UTF-8 encoded bytes representing the string.
39+
Returns:
40+
bytes: The UTF-8 encoded bytes representing the string.
4141
"""
4242
return string.encode("utf-8")
4343

4444

4545
def TimeFromTicks(ticks, tz=None):
4646
"""Construct a DB-API time value from the given ticks value.
4747
48-
:type ticks: float
49-
:param ticks:
50-
a number of seconds since the epoch; see the documentation of the
51-
standard Python time module for details.
48+
Args:
49+
ticks (float):
50+
a number of seconds since the epoch; see the documentation of the
51+
standard Python time module for details.
5252
53-
:type tz: :class:`datetime.tzinfo`
54-
:param tz: (Optional) time zone to use for conversion
53+
tz (datetime.tzinfo): (Optional) time zone to use for conversion
5554
56-
:rtype: :class:`datetime.time`
57-
:returns: time represented by ticks.
55+
Returns:
56+
datetime.time: time represented by ticks.
5857
"""
5958
dt = datetime.datetime.fromtimestamp(ticks, tz=tz)
6059
return dt.timetz()

bigquery/google/cloud/bigquery/external_config.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ def from_api_repr(cls, resource):
176176
API.
177177
178178
Returns:
179-
:class:`~.external_config.BigtableColumn`:
180-
Configuration parsed from ``resource``.
179+
external_config.BigtableColumn: Configuration parsed from ``resource``.
181180
"""
182181
config = cls()
183182
config._properties = copy.deepcopy(resource)
@@ -249,7 +248,7 @@ def type_(self, value):
249248

250249
@property
251250
def columns(self):
252-
"""List[:class:`~.external_config.BigtableColumn`]: Lists of columns
251+
"""List[BigtableColumn]: Lists of columns
253252
that should be exposed as individual fields.
254253
255254
See
@@ -369,8 +368,7 @@ def from_api_repr(cls, resource):
369368
API.
370369
371370
Returns:
372-
:class:`~.external_config.BigtableOptions`:
373-
Configuration parsed from ``resource``.
371+
BigtableOptions: Configuration parsed from ``resource``.
374372
"""
375373
config = cls()
376374
config._properties = copy.deepcopy(resource)
@@ -476,8 +474,7 @@ def to_api_repr(self):
476474
"""Build an API representation of this object.
477475
478476
Returns:
479-
Dict[str, Any]:
480-
A dictionary in the format used by the BigQuery API.
477+
Dict[str, Any]: A dictionary in the format used by the BigQuery API.
481478
"""
482479
return copy.deepcopy(self._properties)
483480

@@ -493,8 +490,7 @@ def from_api_repr(cls, resource):
493490
API.
494491
495492
Returns:
496-
:class:`~.external_config.CSVOptions`:
497-
Configuration parsed from ``resource``.
493+
CSVOptions: Configuration parsed from ``resource``.
498494
"""
499495
config = cls()
500496
config._properties = copy.deepcopy(resource)
@@ -542,8 +538,7 @@ def to_api_repr(self):
542538
"""Build an API representation of this object.
543539
544540
Returns:
545-
Dict[str, Any]:
546-
A dictionary in the format used by the BigQuery API.
541+
Dict[str, Any]: A dictionary in the format used by the BigQuery API.
547542
"""
548543
return copy.deepcopy(self._properties)
549544

@@ -559,8 +554,7 @@ def from_api_repr(cls, resource):
559554
API.
560555
561556
Returns:
562-
:class:`~.external_config.GoogleSheetsOptions`:
563-
Configuration parsed from ``resource``.
557+
GoogleSheetsOptions: Configuration parsed from ``resource``.
564558
"""
565559
config = cls()
566560
config._properties = copy.deepcopy(resource)
@@ -574,7 +568,7 @@ class ExternalConfig(object):
574568
"""Description of an external data source.
575569
576570
Args:
577-
source_format (:class:`~.external_config.ExternalSourceFormat`):
571+
source_format (ExternalSourceFormat):
578572
See :attr:`source_format`.
579573
"""
580574

@@ -719,8 +713,7 @@ def from_api_repr(cls, resource):
719713
API.
720714
721715
Returns:
722-
:class:`~.external_config.ExternalConfig`:
723-
Configuration parsed from ``resource``.
716+
ExternalConfig: Configuration parsed from ``resource``.
724717
"""
725718
config = cls(resource["sourceFormat"])
726719
for optcls in _OPTION_CLASSES:

bigquery/google/cloud/bigquery/model.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ class Model(object):
3434
https://cloud.google.com/bigquery/docs/reference/rest/v2/models
3535
3636
Args:
37-
model_ref (Union[ \
38-
:class:`~google.cloud.bigquery.model.ModelReference`, \
39-
str, \
40-
]):
37+
model_ref (Union[google.cloud.bigquery.model.ModelReference, str]):
4138
A pointer to a model. If ``model_ref`` is a string, it must
4239
included a project ID, dataset ID, and model ID, each separated
4340
by ``.``.

0 commit comments

Comments
 (0)