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

Code before:
# https://aws.amazon.com/apache2.0/
#
# 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.
import os

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,
)

WARNING_MESSAGE_TEMPLATE = """
    .. warning::
        Please note that this method does not function as expected. It is
        recommended to use the :py:meth:`{suggested_py_method_name}`
        :doc:`client method <{suggested_py_method_rel_path}>` instead.
        {extra}
"""
DOCUMENT_ACTION_OVERRIDES = {
    "Metric": {
        "put_data": {
            "ignore_params": ["Namespace"],
            "warning": WARNING_MESSAGE_TEMPLATE.format(
                suggested_py_method_name="put_metric_data",
                suggested_py_method_rel_path=(
                    "../../cloudwatch/client/put_metric_data"
                ),
                extra=(
                    "If you would still like to use this method, please make sure "
                    "that `MetricData[].MetricName` is equal to the metric resource's "
                    "`name` attribute"
                ),
            ),
        }
    }
}


Review comment (bug):
I think there might be something wrong with the spacing/indentation of this message. Your screenshot shows the warning inside of a block quote. You might want to look at the `.rst` file you're generating for this resource's action and see where the actual issue is.

Code after:
# https://aws.amazon.com/apache2.0/
#
# 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.
import os

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)