o .&an$@sPddlZddlZddlmZddlmZddlmZGdddeZ ddZ dS) N)parse_timestamp)escape_controls)sixc@sxeZdZddZddZddZddZ dd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZdS)SharedExampleDocumentercCsJ|j||d|j|||||j||||jdS)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_paragraphwritegetnew_linedocument_input input_shapedocument_output output_shape)selfexampleprefixsectionoperation_modelr=/usr/lib/python3/dist-packages/botocore/docs/sharedexample.pydocument_shared_examples   z/SharedExampleDocumenter.document_shared_examplec Cs|d}|j|dur|||di}|d}|r%|d}|d}||||g||d} | j| j| d| jdS)Ninputcomments parametersz input-closezprint(response))add_new_sectionrstart_codeblockr r _document_paramsr end_codeblock) rrrrshape input_sectionparamsr param_sectionclosing_sectionrrrr (s           z&SharedExampleDocumenter.document_inputcCs|d}|j|d|j|j|di}ddi|d<|d}|r1|d}||||g|d|d}|jdS)NoutputzExpected Output:z...ResponseMetadatarTz output-close)rrr r rr _document_dictr)rrrroutput_sectionr!rr#rrrr9s          z'SharedExampleDocumenter.document_outputcCst|tr||||||dSt|tr ||||||dSt|tjr/||||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) isinstancedictr&list_document_listnumbersNumber_document_number type_name_document_datetime _document_str)rrvaluerpathrrrr _documentJs   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': structuremapz ending-brace},)r_start_nested_valueitemsappendrr _get_commentr r0membersr r3r5pop_end_nested_value)rrr3rr4r top_level dict_sectionkeyval item_section item_comment item_shapedict_section_endrrrr&cs0            z&SharedExampleDocumenter._document_dictc Cs|d}||d|D]E\}}|d|||} | j|||} | r6| | | j| |dd} |rG|j |} | | |||| | q|d} | | ddS)Nz param-values(r7=zending-parenthesis)) rr<r=r>rr r?r r@r r5rArB) rrr3rr4rr"rErFrGrHrIparam_section_endrrrrs$          z(SharedExampleDocumenter._document_paramsc Cs|d}||d|j}t|D]4\}} ||} | j|d||||} | r9| | | j| | | |||| q|d} | | ddS)Nz list-section[z[%s]zending-bracketz],) rr<member enumeraterr r>r?r r5rArB) rrr3rr4r list_sectionrIindexrFrGrHlist_section_endrrrr,s         z&SharedExampleDocumenter._document_listcCs t|}|dt|dS)Nz'%s',)rr r text_type)rrr3r4 safe_valuerrrr2sz%SharedExampleDocumenter._document_strcCs|dt|dS)Nz%s,)r str)rrr3r4rrrr/sz(SharedExampleDocumenter._document_numbercCsRt|}t|d}tdt|D] }|dt||7}q|d|dS)Nrz, z datetime(%s),)r timetuplerWrangelenr )rrr3r4datetime_tuple datetime_strirrrr1s  z*SharedExampleDocumenter._document_datetimecCs0tddd|}|r||vrd||SdS)Nz^\.z# )resubjoin)rr4rrErrrr?s  z$SharedExampleDocumenter._get_commentcCs"|||j|jdSN)r rindent)rrstartrrrr<s  z+SharedExampleDocumenter._start_nested_valuecCs,|j|j|j||dSrc)rdedentr r )rrendrrrrBs   z)SharedExampleDocumenter._end_nested_valueN)F)__name__ __module__ __qualname__rr rr5r&rr,r2r/r1r?r<rBrrrrrs  rcCsP|d}|j|jdt}|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-examplesExamplesid)rrrrN)rrrboldrr)rrexample_prefixshared_examplescontainer_section documenterrrrrdocument_shared_exampless   rr) r`r-botocore.utilsrbotocore.docs.utilsrbotocore.compatrobjectrrrrrrrs     6