2015-11-27 23:25:33 +01:00
|
|
|
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
|
|
# may not use this file except in compliance with the License. A copy of
|
|
|
|
# the License is located at
|
|
|
|
#
|
2021-09-22 18:34:33 +02:00
|
|
|
# https://aws.amazon.com/apache2.0/
|
2015-11-27 23:25:33 +01:00
|
|
|
#
|
|
|
|
# or in the "license" file accompanying this file. This file is
|
|
|
|
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
|
|
# ANY KIND, either express or implied. See the License for the specific
|
|
|
|
# language governing permissions and limitations under the License.
|
2016-05-22 04:03:29 +02:00
|
|
|
from botocore.docs.params import ResponseParamsDocumenter
|
2015-11-27 23:25:33 +01:00
|
|
|
|
|
|
|
from boto3.docs.utils import get_identifier_description
|
|
|
|
|
|
|
|
|
2016-05-22 04:03:29 +02:00
|
|
|
class ResourceShapeDocumenter(ResponseParamsDocumenter):
|
|
|
|
EVENT_NAME = 'resource-shape'
|
|
|
|
|
|
|
|
|
2022-05-26 01:13:54 +02:00
|
|
|
def document_attribute(
|
|
|
|
section,
|
|
|
|
service_name,
|
|
|
|
resource_name,
|
|
|
|
attr_name,
|
|
|
|
event_emitter,
|
|
|
|
attr_model,
|
|
|
|
include_signature=True,
|
|
|
|
):
|
2015-11-27 23:25:33 +01:00
|
|
|
if include_signature:
|
|
|
|
section.style.start_sphinx_py_attr(attr_name)
|
2016-05-22 04:03:29 +02:00
|
|
|
# Note that an attribute may have one, may have many, or may have no
|
|
|
|
# operations that back the resource's shape. So we just set the
|
|
|
|
# operation_name to the resource name if we ever to hook in and modify
|
|
|
|
# a particular attribute.
|
|
|
|
ResourceShapeDocumenter(
|
2022-05-26 01:13:54 +02:00
|
|
|
service_name=service_name,
|
|
|
|
operation_name=resource_name,
|
|
|
|
event_emitter=event_emitter,
|
|
|
|
).document_params(section=section, shape=attr_model)
|
2015-11-27 23:25:33 +01:00
|
|
|
|
|
|
|
|
2022-05-26 01:13:54 +02:00
|
|
|
def document_identifier(
|
|
|
|
section, resource_name, identifier_model, include_signature=True
|
|
|
|
):
|
2015-11-27 23:25:33 +01:00
|
|
|
if include_signature:
|
|
|
|
section.style.start_sphinx_py_attr(identifier_model.name)
|
|
|
|
description = get_identifier_description(
|
2022-05-26 01:13:54 +02:00
|
|
|
resource_name, identifier_model.name
|
|
|
|
)
|
|
|
|
section.write(f'*(string)* {description}')
|
2015-11-27 23:25:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
def document_reference(section, reference_model, include_signature=True):
|
|
|
|
if include_signature:
|
|
|
|
section.style.start_sphinx_py_attr(reference_model.name)
|
2022-05-26 01:13:54 +02:00
|
|
|
reference_type = f'(:py:class:`{reference_model.resource.type}`) '
|
2015-11-27 23:25:33 +01:00
|
|
|
section.write(reference_type)
|
|
|
|
section.include_doc_string(
|
2022-05-26 01:13:54 +02:00
|
|
|
f'The related {reference_model.name} if set, otherwise ``None``.'
|
2015-11-27 23:25:33 +01:00
|
|
|
)
|