|
13 | 13 | import inspect |
14 | 14 | import os |
15 | 15 |
|
| 16 | +from botocore import xform_name |
16 | 17 | from botocore.compat import OrderedDict |
17 | 18 | from botocore.docs.bcdoc.restdoc import DocumentStructure |
18 | 19 | from botocore.docs.example import ResponseExampleDocumenter |
@@ -376,3 +377,56 @@ def _add_response_params(self, section, shape): |
376 | 377 | shape, |
377 | 378 | include=[self._GENERIC_ERROR_SHAPE], |
378 | 379 | ) |
| 380 | + |
| 381 | + |
| 382 | +class ClientContextParamsDocumenter: |
| 383 | + _CONFIG_GUIDE_LINK = ( |
| 384 | + 'https://boto3.amazonaws.com/' |
| 385 | + 'v1/documentation/api/latest/guide/configuration.html' |
| 386 | + ) |
| 387 | + |
| 388 | + OMITTED_CONTEXT_PARAMS = { |
| 389 | + 's3': ( |
| 390 | + 'Accelerate', |
| 391 | + 'DisableMultiRegionAccessPoints', |
| 392 | + 'ForcePathStyle', |
| 393 | + 'UseArnRegion', |
| 394 | + ), |
| 395 | + 's3control': ('UseArnRegion',), |
| 396 | + } |
| 397 | + |
| 398 | + def __init__(self, service_name, context_params): |
| 399 | + self._service_name = service_name |
| 400 | + self._context_params = context_params |
| 401 | + |
| 402 | + def document_context_params(self, section): |
| 403 | + self._add_title(section) |
| 404 | + self._add_overview(section) |
| 405 | + self._add_context_params_list(section) |
| 406 | + |
| 407 | + def _add_title(self, section): |
| 408 | + section.style.h2('Client Context Parameters') |
| 409 | + |
| 410 | + def _add_overview(self, section): |
| 411 | + section.style.new_line() |
| 412 | + section.write( |
| 413 | + 'Client context parameters are configurable on a client ' |
| 414 | + 'instance via the ``client_context_params`` parameter in the ' |
| 415 | + '``Config`` object. For more detailed instructions and examples ' |
| 416 | + 'on the exact usage of context params see the ' |
| 417 | + ) |
| 418 | + section.style.external_link( |
| 419 | + title='configuration guide', |
| 420 | + link=self._CONFIG_GUIDE_LINK, |
| 421 | + ) |
| 422 | + section.write('.') |
| 423 | + section.style.new_line() |
| 424 | + |
| 425 | + def _add_context_params_list(self, section): |
| 426 | + section.style.new_line() |
| 427 | + sn = f'``{self._service_name}``' |
| 428 | + section.writeln(f'The available {sn} client context params are:') |
| 429 | + for param in self._context_params: |
| 430 | + section.style.new_line() |
| 431 | + name = f'``{xform_name(param.name)}``' |
| 432 | + section.write(f'* {name} ({param.type}) - {param.documentation}') |
0 commit comments