Skip to content

Commit b1b0c83

Browse files
authored
docs: Reduce noisy changes in docs regen (#1135)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-api-python-client/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes #386 🦕
1 parent 2c6d029 commit b1b0c83

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

describe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def add_param(pname, desc):
234234
pname = m.group(1)
235235
desc = m.group(2)
236236
add_param(pname, desc)
237-
parameters = ", ".join(parameters)
237+
parameters = ", ".join(sorted(parameters))
238238
else:
239239
parameters = ""
240240
return parameters

googleapiclient/discovery.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,9 @@ def set_parameters(self, method_desc):
898898
comes from the dictionary of methods stored in the 'methods' key in
899899
the deserialized discovery document.
900900
"""
901-
for arg, desc in six.iteritems(method_desc.get("parameters", {})):
901+
parameters = method_desc.get("parameters", {})
902+
sorted_parameters = OrderedDict(sorted(parameters.items()))
903+
for arg, desc in six.iteritems(sorted_parameters):
902904
param = key2param(arg)
903905
self.argmap[param] = arg
904906

@@ -1137,7 +1139,7 @@ def method(self, **kwargs):
11371139
if "body" in all_args:
11381140
args_ordered.append("body")
11391141

1140-
for name in all_args:
1142+
for name in sorted(all_args):
11411143
if name not in args_ordered:
11421144
args_ordered.append(name)
11431145

@@ -1155,7 +1157,7 @@ def method(self, **kwargs):
11551157
paramdoc = paramdesc.get("description", "A parameter")
11561158
if "$ref" in paramdesc:
11571159
docs.append(
1158-
(" %s: object, %s%s%s\n The object takes the" " form of:\n\n%s\n\n")
1160+
(" %s: object, %s%s%s\n The object takes the form of:\n\n%s\n\n")
11591161
% (
11601162
arg,
11611163
paramdoc,

googleapiclient/schema.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
import copy
6767

68+
from collections import OrderedDict
6869
from googleapiclient import _helpers as util
6970

7071

@@ -124,7 +125,7 @@ def prettyPrintByName(self, name):
124125
comments that conforms to the given schema.
125126
"""
126127
# Return with trailing comma and newline removed.
127-
return self._prettyPrintByName(name, seen=[], dent=1)[:-2]
128+
return self._prettyPrintByName(name, seen=[], dent=0)[:-2]
128129

129130
@util.positional(2)
130131
def _prettyPrintSchema(self, schema, seen=None, dent=0):
@@ -155,7 +156,7 @@ def prettyPrintSchema(self, schema):
155156
comments that conforms to the given schema.
156157
"""
157158
# Return with trailing comma and newline removed.
158-
return self._prettyPrintSchema(schema, dent=1)[:-2]
159+
return self._prettyPrintSchema(schema, dent=0)[:-2]
159160

160161
def get(self, name, default=None):
161162
"""Get deserialized JSON schema from the schema name.
@@ -253,7 +254,9 @@ def _to_str_impl(self, schema):
253254
self.emitEnd("{", schema.get("description", ""))
254255
self.indent()
255256
if "properties" in schema:
256-
for pname, pschema in six.iteritems(schema.get("properties", {})):
257+
properties = schema.get("properties", {})
258+
sorted_properties = OrderedDict(sorted(properties.items()))
259+
for pname, pschema in six.iteritems(sorted_properties):
257260
self.emitBegin('"%s": ' % pname)
258261
self._to_str_impl(pschema)
259262
elif "additionalProperties" in schema:

tests/test_schema.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ def datafile(filename):
3232

3333

3434
LOAD_FEED = """{
35-
"items": [
36-
{
37-
"longVal": 42,
38-
"kind": "zoo#loadValue",
39-
"enumVal": "A String",
40-
"anyVal": "", # Anything will do.
41-
"nullVal": None,
42-
"stringVal": "A String",
43-
"doubleVal": 3.14,
44-
"booleanVal": True or False, # True or False.
45-
},
46-
],
47-
"kind": "zoo#loadFeed",
48-
}"""
35+
"items": [
36+
{
37+
"longVal": 42,
38+
"kind": "zoo#loadValue",
39+
"enumVal": "A String",
40+
"anyVal": "", # Anything will do.
41+
"nullVal": None,
42+
"stringVal": "A String",
43+
"doubleVal": 3.14,
44+
"booleanVal": True or False, # True or False.
45+
},
46+
],
47+
"kind": "zoo#loadFeed",
48+
}"""
4949

5050

5151
class SchemasTest(unittest.TestCase):

0 commit comments

Comments
 (0)