Skip to content

Commit 81d92cc

Browse files
committed
Build cleaner and easier to read docs for dynamic surfaces.
Reviewed in http://codereview.appspot.com/6376043/.
1 parent bf14cef commit 81d92cc

File tree

6 files changed

+368
-69
lines changed

6 files changed

+368
-69
lines changed

apiclient/discovery.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
RESERVED_WORDS = ['and', 'assert', 'break', 'class', 'continue', 'def', 'del',
7575
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from',
7676
'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or',
77-
'pass', 'print', 'raise', 'return', 'try', 'while' ]
77+
'pass', 'print', 'raise', 'return', 'try', 'while', 'body']
7878

7979

8080
def fix_method_name(name):
@@ -396,7 +396,9 @@ def createMethod(theclass, methodName, methodDesc, rootDesc):
396396
methodDesc['parameters']['body']['type'] = 'object'
397397
if 'mediaUpload' in methodDesc:
398398
methodDesc['parameters']['media_body'] = {
399-
'description': 'The filename of the media request body.',
399+
'description':
400+
'The filename of the media request body, or an instance of a '
401+
'MediaUpload object.',
400402
'type': 'string',
401403
'required': False,
402404
}
@@ -596,9 +598,20 @@ def method(self, **kwargs):
596598

597599
# Skip undocumented params and params common to all methods.
598600
skip_parameters = rootDesc.get('parameters', {}).keys()
599-
skip_parameters.append(STACK_QUERY_PARAMETERS)
601+
skip_parameters.extend(STACK_QUERY_PARAMETERS)
600602

601-
for arg in argmap.iterkeys():
603+
all_args = argmap.keys()
604+
args_ordered = [key2param(s) for s in methodDesc.get('parameterOrder', [])]
605+
606+
# Move body to the front of the line.
607+
if 'body' in all_args:
608+
args_ordered.append('body')
609+
610+
for name in all_args:
611+
if name not in args_ordered:
612+
args_ordered.append(name)
613+
614+
for arg in args_ordered:
602615
if arg in skip_parameters:
603616
continue
604617

@@ -653,13 +666,13 @@ def createNextMethod(theclass, methodName, methodDesc, rootDesc):
653666
def methodNext(self, previous_request, previous_response):
654667
"""Retrieves the next page of results.
655668
656-
Args:
657-
previous_request: The request for the previous page.
658-
previous_response: The response from the request for the previous page.
669+
Args:
670+
previous_request: The request for the previous page. (required)
671+
previous_response: The response from the request for the previous page. (required)
659672
660-
Returns:
661-
A request object that you can call 'execute()' on to request the next
662-
page. Returns None if there are no more items in the collection.
673+
Returns:
674+
A request object that you can call 'execute()' on to request the next
675+
page. Returns None if there are no more items in the collection.
663676
"""
664677
# Retrieve nextPageToken from previous_response
665678
# Use as pageToken in previous_request to create new request.

0 commit comments

Comments
 (0)