Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/boto3/docs/method.py: 12%
24 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
1# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# https://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License.
13from botocore.docs.method import document_model_driven_method
16def document_model_driven_resource_method(
17 section,
18 method_name,
19 operation_model,
20 event_emitter,
21 method_description=None,
22 example_prefix=None,
23 include_input=None,
24 include_output=None,
25 exclude_input=None,
26 exclude_output=None,
27 document_output=True,
28 resource_action_model=None,
29 include_signature=True,
30):
31 document_model_driven_method(
32 section=section,
33 method_name=method_name,
34 operation_model=operation_model,
35 event_emitter=event_emitter,
36 method_description=method_description,
37 example_prefix=example_prefix,
38 include_input=include_input,
39 include_output=include_output,
40 exclude_input=exclude_input,
41 exclude_output=exclude_output,
42 document_output=document_output,
43 include_signature=include_signature,
44 )
46 # If this action returns a resource modify the return example to
47 # appropriately reflect that.
48 if resource_action_model.resource:
49 if 'return' in section.available_sections:
50 section.delete_section('return')
51 resource_type = resource_action_model.resource.type
53 new_return_section = section.add_new_section('return')
54 return_resource_type = '{}.{}'.format(
55 operation_model.service_model.service_name, resource_type
56 )
58 return_type = f':py:class:`{return_resource_type}`'
59 return_description = f'{resource_type} resource'
61 if _method_returns_resource_list(resource_action_model.resource):
62 return_type = f'list({return_type})'
63 return_description = f'A list of {resource_type} resources'
65 new_return_section.style.new_line()
66 new_return_section.write(f':rtype: {return_type}')
67 new_return_section.style.new_line()
68 new_return_section.write(f':returns: {return_description}')
69 new_return_section.style.new_line()
72def _method_returns_resource_list(resource):
73 for identifier in resource.identifiers:
74 if identifier.path and '[]' in identifier.path:
75 return True
77 return False