<s> from botocore import xform_name <EOL> from botocore . docs . utils import get_official_service_name <EOL> from boto3 . docs . base import BaseDocumenter <EOL> from boto3 . docs . action import ActionDocumenter <EOL> from boto3 . docs . waiter import WaiterResourceDocumenter <EOL> from boto3 . docs . collection import CollectionDocumenter <EOL> from boto3 . docs . subresource import SubResourceDocumenter <EOL> from boto3 . docs . attr import document_attribute <EOL> from boto3 . docs . attr import document_identifier <EOL> from boto3 . docs . attr import document_reference <EOL> from boto3 . docs . utils import get_identifier_args_for_signature <EOL> from boto3 . docs . utils import get_identifier_values_for_example <EOL> from boto3 . docs . utils import get_identifier_description <EOL> from boto3 . docs . utils import add_resource_type_overview <EOL> class ResourceDocumenter ( BaseDocumenter ) : <EOL> def __init__ ( self , resource , botocore_session ) : <EOL> super ( ResourceDocumenter , self ) . __init__ ( resource ) <EOL> self . _botocore_session = botocore_session <EOL> def document_resource ( self , section ) : <EOL> self . _add_title ( section ) <EOL> self . _add_intro ( section ) <EOL> overview_section = section . add_new_section ( '<STR_LIT>' ) <EOL> self . _add_identifiers ( section ) <EOL> self . _add_attributes ( section ) <EOL> self . _add_references ( section ) <EOL> self . _add_actions ( section ) <EOL> self . _add_sub_resources ( section ) <EOL> self . _add_collections ( section ) <EOL> self . _add_waiters ( section ) <EOL> self . _add_overview_of_members ( overview_section ) <EOL> def _add_title ( self , section ) : <EOL> section . style . h2 ( self . _resource_name ) <EOL> def _add_intro ( self , section ) : <EOL> identifier_names = [ ] <EOL> if self . _resource_model . identifiers : <EOL> for identifier in self . _resource_model . identifiers : <EOL> identifier_names . append ( identifier . name ) <EOL> class_args = get_identifier_args_for_signature ( identifier_names ) <EOL> section . style . start_sphinx_py_class ( <EOL> class_name = '<STR_LIT>' % ( self . class_name , class_args ) ) <EOL> description_section = section . add_new_section ( '<STR_LIT:description>' ) <EOL> self . _add_description ( description_section ) <EOL> example_section = section . add_new_section ( '<STR_LIT>' ) <EOL> self . _add_example ( example_section , identifier_names ) <EOL> param_section = section . add_new_section ( '<STR_LIT>' ) <EOL> self . _add_params_description ( param_section , identifier_names ) <EOL> def _add_description ( self , section ) : <EOL> official_service_name = get_official_service_name ( <EOL> self . _service_model ) <EOL> section . write ( <EOL> '<STR_LIT>' % ( <EOL> official_service_name , self . _resource_name ) ) <EOL> def _add_example ( self , section , identifier_names ) : <EOL> section . style . start_codeblock ( ) <EOL> section . style . new_line ( ) <EOL> section . write ( '<STR_LIT>' ) <EOL> section . style . new_line ( ) <EOL> section . style . new_line ( ) <EOL> section . write ( <EOL> '<STR_LIT>' % ( <EOL> self . _service_name , self . _service_name ) <EOL> ) <EOL> section . style . new_line ( ) <EOL> example_values = get_identifier_values_for_example ( identifier_names ) <EOL> section . write ( <EOL> '<STR_LIT>' % ( <EOL> xform_name ( self . _resource_name ) , self . _service_name , <EOL> self . _resource_name , example_values ) ) <EOL> section . style . end_codeblock ( ) <EOL> def _add_params_description ( self , section , identifier_names ) : <EOL> for identifier_name in identifier_names : <EOL> description = get_identifier_description ( <EOL> self . _resource_name , identifier_name ) <EOL> section . write ( '<STR_LIT>' % identifier_name ) <EOL> section . style . new_line ( ) <EOL> section . write ( '<STR_LIT>' % ( <EOL> identifier_name , description ) ) <EOL> section . style . new_line ( ) <EOL> def _add_overview_of_members ( self , section ) : <EOL> for resource_member_type in self . member_map : <EOL> section . style . new_line ( ) <EOL> section . write ( '<STR_LIT>' % ( <EOL> resource_member_type ) ) <EOL> section . style . new_line ( ) <EOL> for member in self . member_map [ resource_member_type ] : <EOL> if resource_member_type in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] : <EOL> section . style . li ( '<STR_LIT>' % member ) <EOL> else : <EOL> section . style . li ( '<STR_LIT>' % member ) <EOL> def _add_identifiers ( self , section ) : <EOL> identifiers = self . _resource . meta . resource_model . identifiers <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> member_list = [ ] <EOL> if identifiers : <EOL> self . member_map [ '<STR_LIT>' ] = member_list <EOL> add_resource_type_overview ( <EOL> section = section , <EOL> resource_type = '<STR_LIT>' , <EOL> description = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> intro_link = '<STR_LIT>' ) <EOL> for identifier in identifiers : <EOL> identifier_section = section . add_new_section ( identifier . name ) <EOL> member_list . append ( identifier . name ) <EOL> document_identifier ( <EOL> section = identifier_section , <EOL> resource_name = self . _resource_name , <EOL> identifier_model = identifier <EOL> ) <EOL> def _add_attributes ( self , section ) : <EOL> service_model = self . _resource . meta . client . meta . service_model <EOL> attributes = { } <EOL> if self . _resource . meta . resource_model . shape : <EOL> shape = service_model . shape_for ( <EOL> self . _resource . meta . resource_model . shape ) <EOL> attributes = self . _resource . meta . resource_model . get_attributes ( <EOL> shape ) <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> attribute_list = [ ] <EOL> if attributes : <EOL> add_resource_type_overview ( <EOL> section = section , <EOL> resource_type = '<STR_LIT>' , <EOL> description = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> intro_link = '<STR_LIT>' ) <EOL> self . member_map [ '<STR_LIT>' ] = attribute_list <EOL> for attr_name in sorted ( attributes ) : <EOL> _ , attr_shape = attributes [ attr_name ] <EOL> attribute_section = section . add_new_section ( attr_name ) <EOL> attribute_list . append ( attr_name ) <EOL> document_attribute ( <EOL> section = attribute_section , <EOL> service_name = self . _service_name , <EOL> resource_name = self . _resource_name , <EOL> attr_name = attr_name , <EOL> event_emitter = self . _resource . meta . client . meta . events , <EOL> attr_model = attr_shape <EOL> ) <EOL> def _add_references ( self , section ) : <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> references = self . _resource . meta . resource_model . references <EOL> reference_list = [ ] <EOL> if references : <EOL> add_resource_type_overview ( <EOL> section = section , <EOL> resource_type = '<STR_LIT>' , <EOL> description = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> intro_link = '<STR_LIT>' ) <EOL> self . member_map [ '<STR_LIT>' ] = reference_list <EOL> for reference in references : <EOL> reference_section = section . add_new_section ( reference . name ) <EOL> reference_list . append ( reference . name ) <EOL> document_reference ( <EOL> section = reference_section , <EOL> reference_model = reference <EOL> ) <EOL> def _add_actions ( self , section ) : <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> actions = self . _resource . meta . resource_model . actions <EOL> if actions : <EOL> documenter = ActionDocumenter ( self . _resource ) <EOL> documenter . member_map = self . member_map <EOL> documenter . document_actions ( section ) <EOL> def _add_sub_resources ( self , section ) : <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> sub_resources = self . _resource . meta . resource_model . subresources <EOL> if sub_resources : <EOL> documenter = SubResourceDocumenter ( self . _resource ) <EOL> documenter . member_map = self . member_map <EOL> documenter . document_sub_resources ( section ) <EOL> def _add_collections ( self , section ) : <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> collections = self . _resource . meta . resource_model . collections <EOL> if collections : <EOL> documenter = CollectionDocumenter ( self . _resource ) <EOL> documenter . member_map = self . member_map <EOL> documenter . document_collections ( section ) <EOL> def _add_waiters ( self , section ) : <EOL> section = section . add_new_section ( '<STR_LIT>' ) <EOL> waiters = self . _resource . meta . resource_model . waiters <EOL> if waiters : <EOL> service_waiter_model = self . _botocore_session . get_waiter_model ( <EOL> self . _service_name ) <EOL> documenter = WaiterResourceDocumenter ( <EOL> self . _resource , service_waiter_model ) <EOL> documenter . member_map = self . member_map <EOL> documenter . document_resource_waiters ( section ) <EOL> class ServiceResourceDocumenter ( ResourceDocumenter ) : <EOL> @ property <EOL> def class_name ( self ) : <EOL> return '<STR_LIT>' % self . _service_docs_name <EOL> def _add_title ( self , section ) : <EOL> section . style . h2 ( '<STR_LIT>' ) <EOL> def _add_description ( self , section ) : <EOL> official_service_name = get_official_service_name ( <EOL> self . _service_model ) <EOL> section . write ( <EOL> '<STR_LIT>' % official_service_name ) <EOL> def _add_example ( self , section , identifier_names ) : <EOL> section . style . start_codeblock ( ) <EOL> section . style . new_line ( ) <EOL> section . write ( '<STR_LIT>' ) <EOL> section . style . new_line ( ) <EOL> section . style . new_line ( ) <EOL> section . write ( <EOL> '<STR_LIT>' % ( <EOL> self . _service_name , self . _service_name ) ) <EOL> section . style . end_codeblock ( ) </s>
