|
13 | 13 | import inspect |
14 | 14 |
|
15 | 15 | import jmespath |
| 16 | +from botocore.docs.utils import DocumentModifiedShape # noqa: F401 |
16 | 17 |
|
17 | 18 |
|
18 | 19 | def get_resource_ignore_params(params): |
@@ -82,65 +83,3 @@ def add_resource_type_overview( |
82 | 83 | f':ref:`Resources Introduction Guide<{intro_link}>`.' |
83 | 84 | ) |
84 | 85 | 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}) -- ') |
0 commit comments