U n‰^n$ã@sPddlZddlZddlmZddlmZddlmZGdd„deƒZ dd„Z dS) éN)Úparse_timestamp)Úescape_controls)Úsixc@sveZdZdd„Zdd„Zdd„Zdd„Zdd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)ÚSharedExampleDocumentercCsJ|j ¡| | d¡¡|j ¡| ||||j¡| |||j¡dS)a8Documents a single shared example based on its definition. :param example: The model of the example :param prefix: The prefix to use in the method example. :param section: The section to write to. :param operation_model: The model of the operation used in the example Ú descriptionN) ÚstyleÚ new_paragraphÚwriteÚgetÚnew_lineÚdocument_inputZ input_shapeÚdocument_outputZ output_shape)ÚselfÚexampleÚprefixÚsectionÚoperation_model©rúu/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/botocore/botocore/docs/sharedexample.pyÚdocument_shared_examples   ÿz/SharedExampleDocumenter.document_shared_examplec Csœ| d¡}|j ¡|dk r&| |¡| di¡}| d¡}|rJ| d¡}| d¡}| |||g|¡| d¡} | j ¡| j ¡|  d¡| j ¡dS)NÚinputÚcommentsÚ parametersz input-closezprint(response))Úadd_new_sectionrÚstart_codeblockr r Ú_document_paramsr Ú end_codeblock) rrrrÚshapeZ input_sectionÚparamsrÚ param_sectionÚclosing_sectionrrrr (s           z&SharedExampleDocumenter.document_inputcCsŽ| d¡}|j ¡| d¡|j ¡|j ¡| di¡}ddi|d<| d¡}|rb| d¡}| |||g|d¡| d¡}|j ¡dS)NÚoutputzExpected Output:z...ZResponseMetadatarTz output-close)rrr r rr Ú_document_dictr)rrrrZoutput_sectionrrr rrrr 9s          z'SharedExampleDocumenter.document_outputcCsˆt|tƒr| |||||¡nft|tƒr<| |||||¡nHt|tjƒrX| |||¡n,|rv|jdkrv|  |||¡n|  |||¡dS)a :param section: The section to add the docs to. :param value: The input / output values representing the parameters that are included in the example. :param comments: The dictionary containing all the comments to be applied to the example. :param path: A list describing where the documenter is in traversing the parameters. This is used to find the equivalent location in the comments dictionary. Ú timestampN) Ú isinstanceÚdictr"ÚlistÚ_document_listÚnumbersÚNumberÚ_document_numberÚ type_nameÚ_document_datetimeÚ _document_str)rrÚvaluerÚpathrrrrÚ _documentJs   z!SharedExampleDocumenter._documentFcCsî| d¡}| |d¡| ¡D]¦\}} | d|¡| |¡} | j ¡| ||¡} | rl|  | ¡| j ¡|  d|¡d} |rª|jdkrš|j   |¡} n|jdkrª|j } |  | | ||| ¡|  ¡q| d¡} | | d¡|sê|  d ¡dS) Nz dict-valueÚ{ú.%sz'%s': Z structureÚmapz ending-braceÚ}ú,)rÚ_start_nested_valueÚitemsÚappendrr Ú _get_commentr r+Úmembersr r.r0ÚpopÚ_end_nested_value)rrr.rr/rZ top_levelZ dict_sectionÚkeyÚvalÚ item_sectionÚ item_commentÚ item_shapeZdict_section_endrrrr"cs.            z&SharedExampleDocumenter._document_dictc CsÄ| d¡}| |d¡| ¡D]Š\}}| d|¡| |¡} | j ¡| ||¡} | rl|  | ¡| j ¡|  |d¡d} |rŽ|j  |¡} |  | |||| ¡|  ¡q| d¡} |  | d¡dS)Nz param-valuesú(r2ú=zending-parenthesisú)) rr6r7r8rr r9r r:r r0r;r<) rrr.rr/rrr=r>r?r@rAZparam_section_endrrrrs$          z(SharedExampleDocumenter._document_paramsc Cs¨| d¡}| |d¡|j}t|ƒD]h\}} | |¡} | j ¡| d|¡| ||¡} | rr|  | ¡| j ¡|  | | |||¡|  ¡q$| d¡} |  | d¡dS)Nz list-sectionú[z[%s]zending-bracketz],) rr6ÚmemberÚ enumeraterr r8r9r r0r;r<) rrr.rr/rZ list_sectionrAÚindexr>r?r@Zlist_section_endrrrr'•s         z&SharedExampleDocumenter._document_listcCs t|ƒ}| dt |¡¡dS)Nz'%s',)rr rÚ text_type)rrr.r/Z safe_valuerrrr-¦sz%SharedExampleDocumenter._document_strcCs| dt|ƒ¡dS)Nz%s,)r Ústr)rrr.r/rrrr*¬sz(SharedExampleDocumenter._document_numbercCsRt|ƒ ¡}t|dƒ}tdt|ƒƒD]}|dt||ƒ7}q&| d|¡dS)Nréz, z datetime(%s),)rÚ timetuplerJÚrangeÚlenr )rrr.r/Zdatetime_tupleZ datetime_strÚirrrr,¯s   z*SharedExampleDocumenter._document_datetimecCs4t ddd |¡¡}|r,||kr,d||SdSdS)Nz^\.Úz# )ÚreÚsubÚjoin)rr/rr=rrrr9¶s  z$SharedExampleDocumenter._get_commentcCs"| |¡|j ¡|j ¡dS©N)r rÚindent)rrÚstartrrrr6½s  z+SharedExampleDocumenter._start_nested_valuecCs,|j ¡|j ¡|j ¡| |¡dSrT)rÚdedentr r )rrÚendrrrr<Âs   z)SharedExampleDocumenter._end_nested_valueN)F)Ú__name__Ú __module__Ú __qualname__rr r r0r"rr'r-r*r,r9r6r<rrrrrsÿ rcCsP| d¡}|j ¡|j d¡tƒ}|D] }|j|| |d¡||dq*dS)aDocuments the shared examples :param section: The section to write to. :param operation_model: The model of the operation. :param example_prefix: The prefix to use in the method example. :param shared_examples: The shared JSON examples from the model. zshared-examplesZExamplesÚid)rrrrN)rrrZboldrr)rrZexample_prefixZshared_examplesZcontainer_sectionZ documenterrrrrÚdocument_shared_examplesÉs    ür]) rQr(Zbotocore.utilsrZbotocore.docs.utilsrZbotocore.compatrÚobjectrr]rrrrÚ s   6