B Üç[ì*ã@sÌddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZGdd„deƒZGdd„deƒZdS)é)Ú xform_name)Úget_official_service_name)ÚBaseDocumenter)ÚActionDocumenter)ÚWaiterResourceDocumenter)ÚCollectionDocumenter)ÚSubResourceDocumenter)Údocument_attribute)Údocument_identifier)Údocument_reference)Ú!get_identifier_args_for_signature)Ú!get_identifier_values_for_example)Úget_identifier_description)Úadd_resource_type_overviewcsŒeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Z‡ZS)ÚResourceDocumentercstt|ƒ |¡||_dS)N)ÚsuperrÚ__init__Ú_botocore_session)ÚselfÚresourceÚbotocore_session)Ú __class__©úT/Users/kashii/Desktop/Projects/Workshops/worker-safety/lambda/boto3/docs/resource.pyrszResourceDocumenter.__init__cCsr| |¡| |¡| d¡}| |¡| |¡| |¡| |¡| |¡| |¡|  |¡|  |¡dS)Nzmember-overview) Ú _add_titleÚ _add_introÚadd_new_sectionÚ_add_identifiersÚ_add_attributesÚ_add_referencesÚ _add_actionsÚ_add_sub_resourcesÚ_add_collectionsÚ _add_waitersÚ_add_overview_of_members)rÚsectionZoverview_sectionrrrÚdocument_resource#s          z$ResourceDocumenter.document_resourcecCs|j |j¡dS)N)ÚstyleÚh2Ú_resource_name)rr%rrrr0szResourceDocumenter._add_titlecCsŽg}|jjr*x|jjD]}| |j¡qWt|ƒ}|jjd|j|fd| d¡}|  |¡| d¡}|  ||¡| d¡}|  ||¡dS)Nz%s(%s))Ú class_nameÚ descriptionÚexampleÚparams) Z_resource_modelÚ identifiersÚappendÚnamer r'Ústart_sphinx_py_classr*rÚ_add_descriptionÚ _add_exampleÚ_add_params_description)rr%Úidentifier_namesÚ identifierZ class_argsÚdescription_sectionÚexample_sectionÚ param_sectionrrrr3s     zResourceDocumenter._add_introcCs"t|jƒ}| d||jf¡dS)Nz A resource representing an %s %s)rÚ_service_modelÚwriter))rr%Úofficial_service_namerrrr2Ks z#ResourceDocumenter._add_descriptioncCsˆ|j ¡|j ¡| d¡|j ¡|j ¡| d|j|jf¡|j ¡t|ƒ}| dt|jƒ|j|j|f¡|j ¡dS)Nz import boto3z%s = boto3.resource('%s')z%s = %s.%s(%s)) r'Ústart_codeblockÚnew_liner;Ú _service_namer rr)Ú end_codeblock)rr%r5Zexample_valuesrrrr3Rs       zResourceDocumenter._add_examplecCsRxL|D]D}t|j|ƒ}| d|¡|j ¡| d||f¡|j ¡qWdS)Nz:type %s: stringz :param %s: %s)rr)r;r'r>)rr%r5Zidentifier_namer+rrrr4ds    z*ResourceDocumenter._add_params_descriptioncCstxn|jD]d}|j ¡| d|¡|j ¡x<|j|D].}|dkrX|j d|¡q:|j d|¡q:WqWdS)Nz&These are the resource's available %s:)r.Ú attributesÚ referencesÚ collectionsz :py:attr:`%s`z:py:meth:`%s()`)Ú member_mapr'r>r;Úli)rr%Zresource_member_typeÚmemberrrrr$ns   z+ResourceDocumenter._add_overview_of_memberscCsr|jjjj}| d¡}g}|r8||jd<t|ddddx4|D],}| |j¡}| |j¡t ||j |dq>WdS)Nr.Z IdentifierszXIdentifiers are properties of a resource that are set upon instantation of the resource.Úidentifiers_attributes_intro)r%Ú resource_typer+Ú intro_link)r%Ú resource_nameÚidentifier_model) Ú _resourceÚmetaÚresource_modelr.rrDrr0r/r r))rr%r.Z member_listr6Zidentifier_sectionrrrr{s"      z#ResourceDocumenter._add_identifiersc CsÄ|jjjjj}i}|jjjjr@| |jjjj¡}|jjj |¡}| d¡}g}|rlt |dddd||j d<xRt |ƒD]F}||\}}| |¡} |  |¡t | |j|j||jjjjj|dqvWdS)NrAZ Attributesz”Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the :py:meth:`load` method.rG)r%rHr+rI)r%Ú service_namerJÚ attr_nameÚ event_emitterÚ attr_model)rLrMÚclientÚ service_modelrNÚshapeÚ shape_forÚget_attributesrrrDÚsortedr/r r?r)Úevents) rr%rTrArUZattribute_listrPÚ_Z attr_shapeZattribute_sectionrrrr‘s6        z"ResourceDocumenter._add_attributescCsn| d¡}|jjjj}g}|r8t|dddd||jd<x0|D](}| |j¡}| |j¡t ||dq>WdS)NrBZ ReferenceszNReferences are related resource instances that have a belongs-to relationship.Zreferences_intro)r%rHr+rI)r%Úreference_model) rrLrMrNrBrrDr0r/r )rr%rBZreference_listÚ referenceZreference_sectionrrrr³s       z"ResourceDocumenter._add_referencescCs:| d¡}|jjjj}|r6t|jƒ}|j|_| |¡dS)NÚactions)rrLrMrNr]rrDZdocument_actions)rr%r]Ú documenterrrrr Ès    zResourceDocumenter._add_actionscCs:| d¡}|jjjj}|r6t|jƒ}|j|_| |¡dS)Nz sub-resources)rrLrMrNÚ subresourcesrrDZdocument_sub_resources)rr%Z sub_resourcesr^rrrr!Ðs    z%ResourceDocumenter._add_sub_resourcescCs:| d¡}|jjjj}|r6t|jƒ}|j|_| |¡dS)NrC)rrLrMrNrCrrDZdocument_collections)rr%rCr^rrrr"Øs    z#ResourceDocumenter._add_collectionscCsJ| d¡}|jjjj}|rF|j |j¡}t|j|ƒ}|j |_ |  |¡dS)NÚwaiters) rrLrMrNr`rÚget_waiter_modelr?rrDZdocument_resource_waiters)rr%r`Úservice_waiter_modelr^rrrr#às   zResourceDocumenter._add_waiters)Ú__name__Ú __module__Ú __qualname__rr&rrr2r3r4r$rrrr r!r"r#Ú __classcell__rr)rrrs    "rc@s0eZdZedd„ƒZdd„Zdd„Zdd„Zd S) ÚServiceResourceDocumentercCs d|jS)Nz%s.ServiceResource)Z_service_docs_name)rrrrr*ísz$ServiceResourceDocumenter.class_namecCs|j d¡dS)NzService Resource)r'r()rr%rrrrñsz$ServiceResourceDocumenter._add_titlecCst|jƒ}| d|¡dS)NzA resource representing %s)rr:r;)rr%r<rrrr2ôsz*ServiceResourceDocumenter._add_descriptioncCsV|j ¡|j ¡| d¡|j ¡|j ¡| d|j|jf¡|j ¡dS)Nz import boto3z%s = boto3.resource('%s'))r'r=r>r;r?r@)rr%r5rrrr3ús     z&ServiceResourceDocumenter._add_exampleN)rcrdreÚpropertyr*rr2r3rrrrrgìs rgN)ÚbotocorerÚbotocore.docs.utilsrZboto3.docs.baserZboto3.docs.actionrZboto3.docs.waiterrZboto3.docs.collectionrZboto3.docs.subresourcerZboto3.docs.attrr r r Zboto3.docs.utilsr r rrrrgrrrrÚ s              O