Skip to content

Commit 325a059

Browse files
authored
Remove DocumentModifiedShape and re-export it from botocore (#4795)
1 parent 447ab8f commit 325a059

2 files changed

Lines changed: 3 additions & 64 deletions

File tree

‎boto3/docs/utils.py‎

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import inspect
1414

1515
import jmespath
16+
from botocore.docs.utils import DocumentModifiedShape # noqa: F401
1617

1718

1819
def get_resource_ignore_params(params):
@@ -82,65 +83,3 @@ def add_resource_type_overview(
8283
f':ref:`Resources Introduction Guide<{intro_link}>`.'
8384
)
8485
section.style.new_line()
85-
86-
87-
class DocumentModifiedShape:
88-
def __init__(
89-
self, shape_name, new_type, new_description, new_example_value
90-
):
91-
self._shape_name = shape_name
92-
self._new_type = new_type
93-
self._new_description = new_description
94-
self._new_example_value = new_example_value
95-
96-
def replace_documentation_for_matching_shape(
97-
self, event_name, section, **kwargs
98-
):
99-
if self._shape_name == section.context.get('shape'):
100-
self._replace_documentation(event_name, section)
101-
for section_name in section.available_sections:
102-
sub_section = section.get_section(section_name)
103-
if self._shape_name == sub_section.context.get('shape'):
104-
self._replace_documentation(event_name, sub_section)
105-
else:
106-
self.replace_documentation_for_matching_shape(
107-
event_name, sub_section
108-
)
109-
110-
def _replace_documentation(self, event_name, section):
111-
if event_name.startswith(
112-
'docs.request-example'
113-
) or event_name.startswith('docs.response-example'):
114-
section.remove_all_sections()
115-
section.clear_text()
116-
section.write(self._new_example_value)
117-
118-
if event_name.startswith(
119-
'docs.request-params'
120-
) or event_name.startswith('docs.response-params'):
121-
allowed_sections = (
122-
'param-name',
123-
'param-documentation',
124-
'end-structure',
125-
'param-type',
126-
'end-param',
127-
)
128-
for section_name in section.available_sections:
129-
# Delete any extra members as a new shape is being
130-
# used.
131-
if section_name not in allowed_sections:
132-
section.delete_section(section_name)
133-
134-
# Update the documentation
135-
description_section = section.get_section('param-documentation')
136-
description_section.clear_text()
137-
description_section.write(self._new_description)
138-
139-
# Update the param type
140-
type_section = section.get_section('param-type')
141-
if type_section.getvalue().decode('utf-8').startswith(':type'):
142-
type_section.clear_text()
143-
type_section.write(f':type {section.name}: {self._new_type}')
144-
else:
145-
type_section.clear_text()
146-
type_section.style.italics(f'({self._new_type}) -- ')

‎tests/functional/docs/test_dynamodb.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_document_interface_is_documented(self):
8989
':param Item: **[REQUIRED]**',
9090
'- *(string) --*',
9191
(
92-
'- *(valid DynamoDB type) -- *- The value of the '
92+
'- *(valid DynamoDB type) --* - The value of the '
9393
'attribute. The valid value types are listed in the '
9494
':ref:`DynamoDB Reference Guide<ref_valid_dynamodb_types>`.'
9595
),
@@ -106,7 +106,7 @@ def test_document_interface_is_documented(self):
106106
'- **Attributes** *(dict) --*',
107107
'- *(string) --*',
108108
(
109-
'- *(valid DynamoDB type) -- *- The value of '
109+
'- *(valid DynamoDB type) --* - The value of '
110110
'the attribute. The valid value types are listed in the '
111111
':ref:`DynamoDB Reference Guide<ref_valid_dynamodb_types>`.'
112112
),

0 commit comments

Comments
 (0)