Repository: boto/boto3
File: boto3/docs/action.py (Python)

Code before:

from botocore import xform_name
from botocore.docs.bcdoc.restdoc import DocumentStructure
from botocore.docs.method import (
    document_custom_method,
    document_model_driven_method,
)
from botocore.model import OperationModel
from botocore.utils import get_service_module_name

from boto3.docs.base import NestedDocumenter
from boto3.docs.method import document_model_driven_resource_method
from boto3.docs.utils import (
    add_resource_type_overview,
    get_resource_ignore_params,
    get_resource_public_actions,
)

PUT_DATA_WARNING_MESSAGE = """
.. warning::
    It is recommended to use the :py:meth:`put_metric_data`
    :doc:`client method <../../cloudwatch/client/put_metric_data>`
    instead. If you would still like to use this resource method,
    please make sure that ``MetricData[].MetricName`` is equal to
    the metric resource's ``name`` attribute.
"""


class ActionDocumenter(NestedDocumenter):
    def document_actions(self, section):
        modeled_actions_list = self._resource_model.actions
        modeled_actions = {}
        for modeled_action in modeled_actions_list:
            modeled_actions[modeled_action.name] = modeled_action
        resource_actions = get_resource_public_actions(
            self._resource.__class__
        )
        self.member_map['actions'] = sorted(resource_actions)
        add_resource_type_overview(
            section=section,
            resource_type='Actions',
            description=(
                'Actions call operations on resources.  They may '
                'automatically handle the passing in of arguments set '
                'from identifiers and some attributes.'
            ),
            intro_link='actions_intro',
        )

        for action_name in sorted(resource_actions):
            # Create a new DocumentStructure for each action and add contents.

Review comment (suggestion):
```suggestion
PUT_DATA_WARNING_MESSAGE = """
.. warning::
    It is recommended to use the :py:meth:`put_metric_data`
    :doc:`client method <../../cloudwatch/client/put_metric_data>`
    instead. If you would still like to use this resource method,
    please make sure that ``MetricData[].MetricName`` is equal to
    the metric resource's ``name`` attribute.
"""

WARNING_MESSAGES = {
    "Metric": {
        "put_metric_data": PUT_DATA_WARNING_MESSAGE
    }
}
```

Code after:

from botocore import xform_name
from botocore.docs.bcdoc.restdoc import DocumentStructure
from botocore.docs.method import (
    document_custom_method,
    document_model_driven_method,
)
from botocore.model import OperationModel
from botocore.utils import get_service_module_name

from boto3.docs.base import NestedDocumenter
from boto3.docs.method import document_model_driven_resource_method
from boto3.docs.utils import (
    add_resource_type_overview,
    get_resource_ignore_params,
    get_resource_public_actions,
)

PUT_DATA_WARNING_MESSAGE = """
.. warning::
    It is recommended to use the :py:meth:`put_metric_data`
    :doc:`client method <../../cloudwatch/client/put_metric_data>`
    instead. If you would still like to use this resource method,
    please make sure that ``MetricData[].MetricName`` is equal to
    the metric resource's ``name`` attribute.
"""

WARNING_MESSAGES = {
    "Metric": {"put_data": PUT_DATA_WARNING_MESSAGE},
}

IGNORE_PARAMS = {"Metric": {"put_data": ["Namespace"]}}


class ActionDocumenter(NestedDocumenter):
    def document_actions(self, section):
        modeled_actions_list = self._resource_model.actions
        modeled_actions = {}
        for modeled_action in modeled_actions_list:
            modeled_actions[modeled_action.name] = modeled_action
        resource_actions = get_resource_public_actions(
            self._resource.__class__
        )
        self.member_map['actions'] = sorted(resource_actions)
        add_resource_type_overview(
            section=section,
            resource_type='Actions',
            description=(
                'Actions call operations on resources.  They may '
                'automatically handle the passing in of arguments set '
                'from identifiers and some attributes.'