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 🦕
diff --git a/describe.py b/describe.py
index 2537e7c..0b7d10f 100755
--- a/describe.py
+++ b/describe.py
@@ -234,7 +234,7 @@
pname = m.group(1)
desc = m.group(2)
add_param(pname, desc)
- parameters = ", ".join(parameters)
+ parameters = ", ".join(sorted(parameters))
else:
parameters = ""
return parameters
diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py
index 6363809..b5d4696 100644
--- a/googleapiclient/discovery.py
+++ b/googleapiclient/discovery.py
@@ -898,7 +898,9 @@
comes from the dictionary of methods stored in the 'methods' key in
the deserialized discovery document.
"""
- for arg, desc in six.iteritems(method_desc.get("parameters", {})):
+ parameters = method_desc.get("parameters", {})
+ sorted_parameters = OrderedDict(sorted(parameters.items()))
+ for arg, desc in six.iteritems(sorted_parameters):
param = key2param(arg)
self.argmap[param] = arg
@@ -1137,7 +1139,7 @@
if "body" in all_args:
args_ordered.append("body")
- for name in all_args:
+ for name in sorted(all_args):
if name not in args_ordered:
args_ordered.append(name)
@@ -1155,7 +1157,7 @@
paramdoc = paramdesc.get("description", "A parameter")
if "$ref" in paramdesc:
docs.append(
- (" %s: object, %s%s%s\n The object takes the" " form of:\n\n%s\n\n")
+ (" %s: object, %s%s%s\n The object takes the form of:\n\n%s\n\n")
% (
arg,
paramdoc,
diff --git a/googleapiclient/schema.py b/googleapiclient/schema.py
index 022cb0a..2d58984 100644
--- a/googleapiclient/schema.py
+++ b/googleapiclient/schema.py
@@ -65,6 +65,7 @@
import copy
+from collections import OrderedDict
from googleapiclient import _helpers as util
@@ -124,7 +125,7 @@
comments that conforms to the given schema.
"""
# Return with trailing comma and newline removed.
- return self._prettyPrintByName(name, seen=[], dent=1)[:-2]
+ return self._prettyPrintByName(name, seen=[], dent=0)[:-2]
@util.positional(2)
def _prettyPrintSchema(self, schema, seen=None, dent=0):
@@ -155,7 +156,7 @@
comments that conforms to the given schema.
"""
# Return with trailing comma and newline removed.
- return self._prettyPrintSchema(schema, dent=1)[:-2]
+ return self._prettyPrintSchema(schema, dent=0)[:-2]
def get(self, name, default=None):
"""Get deserialized JSON schema from the schema name.
@@ -253,7 +254,9 @@
self.emitEnd("{", schema.get("description", ""))
self.indent()
if "properties" in schema:
- for pname, pschema in six.iteritems(schema.get("properties", {})):
+ properties = schema.get("properties", {})
+ sorted_properties = OrderedDict(sorted(properties.items()))
+ for pname, pschema in six.iteritems(sorted_properties):
self.emitBegin('"%s": ' % pname)
self._to_str_impl(pschema)
elif "additionalProperties" in schema:
diff --git a/tests/test_schema.py b/tests/test_schema.py
index 1732d85..f5fd518 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -32,20 +32,20 @@
LOAD_FEED = """{
- "items": [
- {
- "longVal": 42,
- "kind": "zoo#loadValue",
- "enumVal": "A String",
- "anyVal": "", # Anything will do.
- "nullVal": None,
- "stringVal": "A String",
- "doubleVal": 3.14,
- "booleanVal": True or False, # True or False.
- },
- ],
- "kind": "zoo#loadFeed",
- }"""
+ "items": [
+ {
+ "longVal": 42,
+ "kind": "zoo#loadValue",
+ "enumVal": "A String",
+ "anyVal": "", # Anything will do.
+ "nullVal": None,
+ "stringVal": "A String",
+ "doubleVal": 3.14,
+ "booleanVal": True or False, # True or False.
+ },
+ ],
+ "kind": "zoo#loadFeed",
+}"""
class SchemasTest(unittest.TestCase):