
    #                     F    S SK r S SKrS SKJr  S SKJr   " S S5      rS rg)    N)escape_controls)parse_timestampc                   h    \ rS rSrS rS rS rS r SS jrS r	S r
S	 rS
 rS rS rS rS rSrg)SharedExampleDocumenter   c                    UR                   R                  5         UR                  UR                  S5      5        UR                   R	                  5         U R                  X1X$R                  5        U R                  X1UR                  5        g)a  Documents 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_models        .lib/third_party/botocore/docs/sharedexample.pydocument_shared_example/SharedExampleDocumenter.document_shared_example   sj     	##%gkk-01 f&A&A	
 	W/K/KL    c                 "   UR                  S5      nUR                  R                  5         Ub  UR                  U5        UR	                  S0 5      nUR	                  S5      nU(       a  UR	                  S5      nUR                  S5      nU R                  XU/ U5        UR                  S5      n	U	R                  R                  5         U	R                  R                  5         U	R                  S5        U	R                  R                  5         g )Ninputcomments
parameterszinput-closezprint(response))add_new_sectionr
   start_codeblockr   r   _document_paramsr   end_codeblock)
r   r   r   r   shapeinput_sectionparamsr   param_sectionclosing_sections
             r   r   &SharedExampleDocumenter.document_input*   s    //8++-'Wb);;z*||G,H%55lCmXr5I'77F&&(&&(/0++-r   c                    UR                  S5      nUR                  R                  5         UR                  S5        UR                  R                  5         UR                  R	                  5         UR                  S0 5      nSS0US'   UR                  S5      nU(       a  UR                  S5      nU R                  XEU/ US5        UR                  S5      nUR                  R                  5         g )NoutputzExpected Output:z...ResponseMetadatar   Tzoutput-close)r    r
   r   r   r!   r   _document_dictr#   )r   r   r   r$   output_sectionr&   r   r(   s           r   r   'SharedExampleDocumenter.document_output;   s     00:%%'/0%%',,.Xr* ',U^!";;z*||H-HNHb%N(88H++-r   c                    [        U[        5      (       a  U R                  XX4U5        g[        U[        5      (       a  U R	                  XX4U5        g[        U[
        R                  5      (       a  U R                  XU5        gU(       a#  UR                  S:X  a  U R                  XU5        gU R                  XU5        g)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   pathr$   s         r   	_document!SharedExampleDocumenter._documentL   s     eT""Ft$$Fw~~..!!'$7u+5##GD9wt4r   c                    UR                  S5      nU R                  US5        UR                  5        GH  u  pUR                  SU-  5        UR                  U5      n
U
R                  R                  5         U R                  XC5      nU(       a+  U
R                  U5        U
R                  R                  5         U
R                  SU-  5        S nU(       aH  UR                  S:X  a  UR                  R                  U5      nOUR                  S:X  a  UR                  nU R                  XX4U5        UR                  5         GM     UR                  S5      nU R                  US5        U(       d  UR                  S	5        g g )
Nz
dict-value{.%sz'%s': 	structuremapzending-brace},)r    _start_nested_valueitemsappendr
   r   _get_commentr   r9   membersr   r<   r>   pop_end_nested_value)r   r   r<   r   r=   r$   	top_leveldict_sectionkeyvalitem_sectionitem_comment
item_shapedict_section_ends                 r   r-   &SharedExampleDocumenter._document_dicte   s?    ..|<  s3HCKK$'77<L''),,T<L""<0""++-x#~. J??k1!&!2!23!7J__-!&JNN<hjIHHJ% && (77G/5""3' r   c                 |   UR                  S5      nU R                  US5        UR                  5        H  u  pxUR                  SU-  5        UR                  U5      n	U	R                  R                  5         U R                  XC5      n
U
(       a+  U	R                  U
5        U	R                  R                  5         U	R                  US-   5        S nU(       a  UR                  R                  U5      nU R                  XX4U5        UR                  5         M     UR                  S5      nU R                  US5        g )Nzparam-values(rB   =zending-parenthesis))r    rG   rH   rI   r
   r   rJ   r   rK   r   r>   rL   rM   )r   r   r<   r   r=   r$   r'   rP   rQ   rR   rS   rT   param_section_ends                r   r"   (SharedExampleDocumenter._document_params   s   //?  4HCKK$(88=L''),,T<L""<0""++-sSy) J"]]..s3
NN<hjIHHJ &  *99:NO0#6r   c                    UR                  S5      nU R                  US5        UR                  n[        U5       H  u  pUR                  U5      n
U
R                  R                  5         UR                  SU-  5        U R                  XC5      nU(       a+  U
R                  U5        U
R                  R                  5         U R                  XX4U5        UR                  5         M     UR                  S5      nU R                  US5        g )Nzlist-section[z[%s]zending-bracketz],)r    rG   member	enumerater
   r   rI   rJ   r   r>   rL   rM   )r   r   r<   r   r=   r$   list_sectionrT   indexrQ   rR   rS   list_section_ends                r   r5   &SharedExampleDocumenter._document_list   s    ..~>  s3\\
#E*JE'77>L'')KK',,T<L""<0""++-NN<hjIHHJ + (778HI/6r   c                 D    [        U5      nUR                  SU S35        g )N'z',)r   r   )r   r   r<   r=   
safe_values        r   r;   %SharedExampleDocumenter._document_str   s#     %U+
*R()r   c                 >    UR                  S[        U5      -  5        g )Nz%s,)r   str)r   r   r<   r=   s       r   r8   (SharedExampleDocumenter._document_number   s    ec%j()r   c                     [        U5      R                  5       n[        US   5      n[        S[	        U5      5       H  nUS[        XF   5      -   -  nM     UR                  SU-  5        g )Nr      z, zdatetime(%s),)r   	timetuplerj   rangelenr   )r   r   r<   r=   datetime_tupledatetime_stris          r   r:   *SharedExampleDocumenter._document_datetime   sb    (/99;>!,-q#n-.AD3~'8#999L /o45r   c                 x    [         R                  " SSSR                  U5      5      nU(       a  X2;   a  SX#   -   $ g)Nz^\. z# )resubjoin)r   r=   r   rP   s       r   rJ   $SharedExampleDocumenter._get_comment   s3    ffVR/(-''r   c                     UR                  U5        UR                  R                  5         UR                  R                  5         g N)r   r
   indent)r   r   starts      r   rG   +SharedExampleDocumenter._start_nested_value   s.    er   c                     UR                   R                  5         UR                   R                  5         UR                   R                  5         UR                  U5        g r|   )r
   dedentr   r   )r   r   ends      r   rM   )SharedExampleDocumenter._end_nested_value   s>     cr    N)F)__name__
__module____qualname____firstlineno__r   r   r   r>   r-   r"   r5   r;   r8   r:   rJ   rG   rM   __static_attributes__r   r   r   r   r      sK    M*."."54 @E(:7,7"**6
r   r   c                     U R                  S5      nUR                  R                  5         UR                  R                  S5        [	        5       nU H'  nUR                  UUR                  US   5      UUS9  M)     g)a   Documents 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.
zshared-examplesExamplesid)r   r   r   r   N)r    r
   r   boldr   r   )r   r   example_prefixshared_examplescontainer_section
documenterr   s          r   document_shared_examplesr      s|      //0AB))+  ,(*J"**%55gdmD!+	 	+ 	
 #r   )r6   rw   botocore.docs.utilsr   botocore.utilsr   r   r   r   r   r   <module>r      s%     	 / *u up
r   