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ÚresourceZbotocore_session)Ú __class__©ú4/tmp/pip-build-uw_ogi45/boto3/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Ú descriptionZexampleÚparams) Z_resource_modelÚ identifiersÚappendÚnamer r&Zstart_sphinx_py_classr)rÚ_add_descriptionÚ _add_exampleÚ_add_params_description)rr$Úidentifier_namesÚ identifierZ class_argsZdescription_sectionZexample_sectionZ param_sectionrrrr3s     zResourceDocumenter._add_introcCs"t|jƒ}| d||jf¡dS)Nz A resource representing an %s %s)rÚ_service_modelÚwriter()rr$Úofficial_service_namerrrr/Ks 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_liner5Ú _service_namer rr(Ú end_codeblock)rr$r2Zexample_valuesrrrr0Rs       zResourceDocumenter._add_examplecCsRxL|D]D}t|j|ƒ}| d|¡|j ¡| d||f¡|j ¡qWdS)Nz:type %s: stringz :param %s: %s)rr(r5r&r8)rr$r2Zidentifier_namer*rrrr1ds    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&r8r5Ú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_nameZidentifier_model) Ú _resourceÚmetaÚresource_modelr,rr>rr.r-r r()rr$r,Z member_listr3Zidentifier_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)Nr;Z 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.rA)r$rBr*rC)r$Z service_namerDÚ attr_nameZ event_emitterZ attr_model)rErFÚclientÚ service_modelrGÚshapeZ shape_forZget_attributesrrr>Úsortedr-r r9r(Úevents) rr$rJr;rKZattribute_listrHÚ_Z attr_shapeZattribute_sectionrrrr‘s6        z"ResourceDocumenter._add_attributescCsn| d¡}|jjjj}g}|r8t|dddd||jd<x0|D](}| |j¡}| |j¡t ||dq>WdS)Nr<Z ReferenceszNReferences are related resource instances that have a belongs-to relationship.Zreferences_intro)r$rBr*rC)r$Zreference_model) rrErFrGr<rr>r.r-r )rr$r<Zreference_listÚ referenceZreference_sectionrrrr³s       z"ResourceDocumenter._add_referencescCs:| d¡}|jjjj}|r6t|jƒ}|j|_| |¡dS)NÚactions)rrErFrGrPrr>Zdocument_actions)rr$rPÚ documenterrrrrÈs    zResourceDocumenter._add_actionscCs:| d¡}|jjjj}|r6t|jƒ}|j|_| |¡dS)Nz sub-resources)rrErFrGZ subresourcesrr>Zdocument_sub_resources)rr$Z sub_resourcesrQrrrr Ðs    z%ResourceDocumenter._add_sub_resourcescCs:| d¡}|jjjj}|r6t|jƒ}|j|_| |¡dS)Nr=)rrErFrGr=rr>Zdocument_collections)rr$r=rQrrrr!Øs    z#ResourceDocumenter._add_collectionscCsJ| d¡}|jjjj}|rF|j |j¡}t|j|ƒ}|j |_ |  |¡dS)NÚwaiters) rrErFrGrRrZget_waiter_modelr9rr>Zdocument_resource_waiters)rr$rRZservice_waiter_modelrQrrrr"às   zResourceDocumenter._add_waiters)Ú__name__Ú __module__Ú __qualname__rr%rrr/r0r1r#rrrrr 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)rr4r5)rr$r6rrrr/ôsz*ServiceResourceDocumenter._add_descriptioncCsV|j ¡|j ¡| d¡|j ¡|j ¡| d|j|jf¡|j ¡dS)Nz import boto3z%s = boto3.resource('%s'))r&r7r8r5r9r:)rr$r2rrrr0ús     z&ServiceResourceDocumenter._add_exampleN)rSrTrUÚpropertyr)rr/r0rrrrrWìs rWN)ZbotocorerZbotocore.docs.utilsrZboto3.docs.baserZboto3.docs.actionrZboto3.docs.waiterrZboto3.docs.collectionrZboto3.docs.subresourcerZboto3.docs.attrr r r Zboto3.docs.utilsr r rrrrWrrrrÚ s              O