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_inputÚ input_shapeÚdocument_outputÚ output_shape)ÚselfÚexampleÚprefixÚsectionÚoperation_model©rú\/Users/kashii/Desktop/Projects/Workshops/worker-safety/lambda/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...ÚResponseMetadatarTz output-close)rrr r rr Ú_document_dictr)rrrrZoutput_sectionr rr"rrrr9s          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': Ú structureÚmapz ending-braceú}ú,)rÚ_start_nested_valueÚitemsÚappendrr Ú _get_commentr r.Úmembersr r1r3ÚpopÚ_end_nested_value)rrr1rr2rZ 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ú)) rr9r:r;rr r<r r=r r3r>r?) rrr1rr2rr!r@rArBrCrDZparam_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],) rr9ÚmemberÚ enumeraterr r;r<r r3r>r?) rrr1rr2rÚ list_sectionrDÚindexrArBrCZlist_section_endrrrr*•s         z&SharedExampleDocumenter._document_listcCs t|ƒ}| dt |¡¡dS)Nz'%s',)rr rÚ text_type)rrr1r2Z safe_valuerrrr0¦sz%SharedExampleDocumenter._document_strcCs| dt|ƒ¡dS)Nz%s,)r Ústr)rrr1r2rrrr-¬sz(SharedExampleDocumenter._document_numbercCsVt|ƒ ¡}t|dƒ}x*tdt|ƒƒD]}|dt||ƒ7}q(W| d|¡dS)Nréz, z datetime(%s),)rÚ timetuplerNÚrangeÚlenr )rrr1r2Zdatetime_tupleZ datetime_strÚirrrr/¯s   z*SharedExampleDocumenter._document_datetimecCs4t ddd |¡¡}|r,||kr,d||SdSdS)Nz^\.Úz# )ÚreÚsubÚjoin)rr2rr@rrrr<¶s  z$SharedExampleDocumenter._get_commentcCs"| |¡|j ¡|j ¡dS)N)r rÚindent)rrÚstartrrrr9½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 rr3r%rr*r0r-r/r<r9r?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)rrÚexample_prefixÚshared_examplesZcontainer_sectionZ documenterrrrrÚdocument_shared_examplesÉs     rc) rUr+Úbotocore.utilsrÚbotocore.docs.utilsrÚbotocore.compatrÚobjectrrcrrrrÚ s   6