o ‰ü?cþ#ã@sBddlZddlZddlmZddlmZGdd„dƒZdd„ZdS)éN)Úescape_controls)Úparse_timestampc@sxeZdZdd„Zdd„Zdd„Zdd„Z dd 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úv/private/var/folders/cw/wlscbxl13mj6wd668h7l9g9sllkg5j/T/pip-target-b31awkwq/lib/python/botocore/docs/sharedexample.pyÚdocument_shared_examples   ÿz/SharedExampleDocumenter.document_shared_examplec Csœ| d¡}|j ¡|dur| |¡| di¡}| d¡}|r%| d¡}| d¡}| |||g|¡| d¡} | j ¡| j ¡|  d¡| j ¡dS)NÚinputÚcommentsÚ parametersz input-closezprint(response))Úadd_new_sectionrÚstart_codeblockrr Ú_document_paramsr Ú end_codeblock) r rrrÚshapeZ input_sectionÚparamsrÚ param_sectionÚclosing_sectionrrrr *s           z&SharedExampleDocumenter.document_inputcCsŽ| d¡}|j ¡| d¡|j ¡|j ¡| di¡}ddi|d<| d¡}|r1| d¡}| |||g|d¡| d¡}|j ¡dS)NÚoutputzExpected Output:z...ZResponseMetadatarTz output-close)rrr rrr Ú_document_dictr)r rrrZoutput_sectionrrrrrrr ;s          z'SharedExampleDocumenter.document_outputcCst|tƒr| |||||¡dSt|tƒr | |||||¡dSt|tjƒr/| |||¡dS|r?|jdkr?|  |||¡dS|  |||¡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)r rÚvaluerÚpathrrrrÚ _documentLs   z!SharedExampleDocumenter._documentFcCsò| d¡}| |d¡| ¡D]S\}} | d|¡| |¡} | j ¡| ||¡} | r6|  | ¡| j ¡|  d|¡d} |rU|jdkrM|j   |¡} n|jdkrU|j } |  | | ||| ¡|  ¡q| d¡} | | d¡|sw|  d ¡dSdS) Nz dict-valueÚ{ú.%sz'%s': Z structureÚmapz ending-braceÚ}ú,)rÚ_start_nested_valueÚitemsÚappendrr Ú _get_commentrr*Úmembersr r-r/ÚpopÚ_end_nested_value)r rr-rr.rZ top_levelZ dict_sectionÚkeyÚvalÚ item_sectionÚ item_commentÚ item_shapeZdict_section_endrrrr!es0            ÿz&SharedExampleDocumenter._document_dictc CsÄ| d¡}| |d¡| ¡D]E\}}| d|¡| |¡} | j ¡| ||¡} | r6|  | ¡| j ¡|  |d¡d} |rG|j  |¡} |  | |||| ¡|  ¡q| d¡} |  | d¡dS)Nz param-valuesú(r1ú=zending-parenthesisú)) rr5r6r7rr r8rr9r r/r:r;) r rr-rr.rrr<r=r>r?r@Zparam_section_endrrrr‚s$          z(SharedExampleDocumenter._document_paramsc Cs¨| d¡}| |d¡|j}t|ƒD]4\}} | |¡} | j ¡| d|¡| ||¡} | r9|  | ¡| j ¡|  | | |||¡|  ¡q| d¡} |  | d¡dS)Nz list-sectionú[z[%s]zending-bracketz],) rr5ÚmemberÚ enumeraterr r7r8rr/r:r;) r rr-rr.rZ list_sectionr@Úindexr=r>r?Zlist_section_endrrrr&˜s         z&SharedExampleDocumenter._document_listcCst|ƒ}| d|›d¡dS)Nú'z',)rr)r rr-r.Z safe_valuerrrr,©sz%SharedExampleDocumenter._document_strcCs| dt|ƒ¡dS)Nz%s,)rÚstr)r rr-r.rrrr)¯sz(SharedExampleDocumenter._document_numbercCsRt|ƒ ¡}t|dƒ}tdt|ƒƒD] }|dt||ƒ7}q| d|¡dS)Nréz, z datetime(%s),)rÚ timetuplerIÚrangeÚlenr)r rr-r.Zdatetime_tupleZ datetime_strÚirrrr+²s  z*SharedExampleDocumenter._document_datetimecCs0t ddd |¡¡}|r||vrd||SdS)Nz^\.Úz# )ÚreÚsubÚjoin)r r.rr<rrrr8¹s  z$SharedExampleDocumenter._get_commentcCs"| |¡|j ¡|j ¡dS©N)rrÚindent)r rÚstartrrrr5Às  z+SharedExampleDocumenter._start_nested_valuecCs,|j ¡|j ¡|j ¡| |¡dSrS)rÚdedentr r)r rÚendrrrr;Ås   z)SharedExampleDocumenter._end_nested_valueN)F)Ú__name__Ú __module__Ú __qualname__rr r r/r!rr&r,r)r+r8r5r;rrrrrs ÿ rcCsP| d¡}|j ¡|j d¡tƒ}|D]}|j|| |d¡||dqdS)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)rrrÚboldrr)rrZexample_prefixZshared_examplesZcontainer_sectionZ documenterrrrrÚdocument_shared_examplesÌs   üÿr])r'rPZbotocore.docs.utilsrZbotocore.utilsrrr]rrrrÚs    9