B 䊇cþ#ã@sBddlZddlZddlmZddlmZGdd„dƒZdd„ZdS)éN)Úescape_controls)Úparse_timestampc@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úv/private/var/folders/8c/hx9_v10d5x38qmnzt13b7b8j1k3n5b/T/pip-target-x6xd5gna/lib/python/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_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¡}|rb| d¡}| |||g|d¡| d¡}|j ¡dS)NÚoutputzExpected Output:z...ZResponseMetadatarTz output-close)rrr rrr Ú_document_dictr)r rrrZoutput_sectionrrrrrrr ;s          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)r rÚvaluerÚpathrrrrÚ _documentLs   z!SharedExampleDocumenter._documentFcCsò| d¡}| |d¡x²| ¡D]¦\}} | d|¡| |¡} | j ¡| ||¡} | rn|  | ¡| j ¡|  d|¡d} |r¬|jdkrœ|j   |¡} n|jdkr¬|j } |  | | ||| ¡|  ¡q W| d¡} | | d¡|sî|  d ¡dS) Nz dict-valueÚ{z.%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!es.            z&SharedExampleDocumenter._document_dictc CsÈ| d¡}| |d¡x–| ¡D]Š\}}| d|¡| |¡} | j ¡| ||¡} | rn|  | ¡| j ¡|  |d¡d} |r|j  |¡} |  | |||| ¡|  ¡q W| d¡} |  | d¡dS)Nz param-valuesú(z.%sú=zending-parenthesisú)) rr4r5r6rr r7rr8r r/r9r:) r rr-rr.rrr;r<r=r>r?Zparam_section_endrrrr‚s$          z(SharedExampleDocumenter._document_paramsc Cs¬| d¡}| |d¡|j}xtt|ƒD]h\}} | |¡} | j ¡| d|¡| ||¡} | rt|  | ¡| j ¡|  | | |||¡|  ¡q&W| d¡} |  | d¡dS)Nz list-sectionú[z[%s]zending-bracketz],) rr4ÚmemberÚ enumeraterr r6r7rr/r9r:) 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_numbercCsVt|ƒ ¡}t|dƒ}x*tdt|ƒƒD]}|dt||ƒ7}q(W| d|¡dS)Nréz, z datetime(%s),)rÚ timetuplerHÚrangeÚlenr)r rr-r.Zdatetime_tupleZ datetime_strÚirrrr+²s   z*SharedExampleDocumenter._document_datetimecCs4t ddd |¡¡}|r,||kr,d||SdSdS)Nz^\.Úz# )ÚreÚsubÚjoin)r r.rr;rrrr7¹s  z$SharedExampleDocumenter._get_commentcCs"| |¡|j ¡|j ¡dS)N)rrÚindent)r rÚstartrrrr4Às  z+SharedExampleDocumenter._start_nested_valuecCs,|j ¡|j ¡|j ¡| |¡dS)N)rÚdedentr r)r rÚendrrrr:Ås   z)SharedExampleDocumenter._end_nested_valueN)F)Ú__name__Ú __module__Ú __qualname__rr r r/r!rr&r,r)r+r7r4r:rrrrrs rcCsT| d¡}|j ¡|j d¡tƒ}x(|D] }|j|| |d¡||dq,WdS)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'rOZbotocore.docs.utilsrZbotocore.utilsrrr[rrrrÚ s   9