B “äî\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ú?/tmp/pip-build-uw_ogi45/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ÚcommentsZ 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_sectionrrrrrrr 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¡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_commentr r*Úmembersr r-r/Ú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¡x–| ¡D]Š\}}| d|¡| |¡} | j ¡| ||¡} | rn|  | ¡| j ¡|  |d¡d} |r|j  |¡} |  | |||| ¡|  ¡q W| d¡} |  | d¡dS)Nz param-valuesú(z.%sú=zending-parenthesisú)) rr4r5r6rr r7r r8r r/r9r:) rrr-rr.rrr;r<r=r>r?Zparam_section_endrrrrs$          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 r6r7r r/r9r:) rrr-rr.rZ list_sectionr?Ú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_numbercCsVt|ƒ ¡}t|dƒ}x*tdt|ƒƒD]}|dt||ƒ7}q(W| d|¡dS)Nréz, z datetime(%s),)rÚ timetuplerHÚ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;rrrr7¶s  z$SharedExampleDocumenter._get_commentcCs"| |¡|j ¡|j ¡dS)N)r rÚindent)rrÚstartrrrr4½s  z+SharedExampleDocumenter._start_nested_valuecCs,|j ¡|j ¡|j ¡| |¡dS)N)rÚdedentr r )rrÚ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)rrrZboldrr)rrZexample_prefixZshared_examplesZcontainer_sectionZ documenterrrrrÚdocument_shared_examplesÉs     rZ) rOr'Zbotocore.utilsrZbotocore.docs.utilsrZbotocore.compatrÚobjectrrZrrrrÚ s   6