
    /Jf#                     N    d dl Z d dlZd dlmZ d dlmZ  G d d          Zd ZdS )    N)escape_controls)parse_timestampc                   `    e Zd Zd Zd Zd Zd Z	 ddZd Zd Z	d	 Z
d
 Zd Zd Zd Zd ZdS )SharedExampleDocumenterc                 ,   |j                                          |                    |                    d                     |j                                          |                     ||||j                   |                     |||j                   dS )a8  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        ^/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/botocore/docs/sharedexample.pydocument_shared_examplez/SharedExampleDocumenter.document_shared_example   s     	##%%%gkk-00111   Wfo&A	
 	
 	
 	Wg/KLLLLL    c                 Z   |                     d          }|j                                         ||                    |           |                    di           }|                    d          }|r|                    d          }|                     d          }|                     |||g |           |                     d          }	|	j                                         |	j                                         |	                    d           |	j                                         d S )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   z&SharedExampleDocumenter.document_input*   s   //88++---'''Wb));;z** 	-||G,,H%55lCCmVXr5III'77FF&&(((&&(((/000++-----r   c                    |                     d          }|j                                         |                    d           |j                                         |j                                         |                    di           }ddi|d<   |                    d          }|r|                    d          }|                     |||g |d           |                     d          }|j                                         d S )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   z'SharedExampleDocumenter.document_output;   s    00::%%'''/000%%''',,...Xr** ',U^!";;z** 	.||H--HNFHb%NNN(88HH++-----r   c                    t          |t                    r|                     |||||           dS t          |t                    r|                     |||||           dS t          |t
          j                  r|                     |||           dS |r$|j        dk    r| 	                    |||           dS | 
                    |||           dS )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   	_documentz!SharedExampleDocumenter._documentL   s     eT"" 		5$FFFFFt$$ 	5$FFFFFw~.. 	5!!'5$77777 	5u+55##GUD99999wt44444r   Fc                 6   |                     d          }|                     |d           |                                D ]\  }}	|                    d|z             |                     |          }
|
j                                         |                     ||          }|r.|
                    |           |
j                                         |
                    d|z             d }|r8|j        dk    r|j	        
                    |          }n|j        dk    r|j        }|                     |
|	|||           |                                 |                     d          }|                     |d           |s|                    d	           d S d S )
Nz
dict-value{.%sz'%s': 	structuremapzending-brace},)r   _start_nested_valueitemsappendr	   r   _get_commentr   r5   membersr   r8   r:   pop_end_nested_value)r   r   r8   r   r9   r"   	top_leveldict_sectionkeyvalitem_sectionitem_comment
item_shapedict_section_ends                 r   r*   z&SharedExampleDocumenter._document_dicte   s    ..|<<  s333 	 	HCKK$$$'77<<L''))),,T8<<L .""<000"++---x#~... J -?k11!&!2!23!7!7JJ_--!&JNN<hjIIIHHJJJJ'77GG/555 	(""3'''''	( 	(r   c                    |                     d          }|                     |d           |                                D ]\  }}|                    d|z             |                     |          }	|	j                                         |                     ||          }
|
r.|	                    |
           |	j                                         |	                    |dz              d }|r|j        	                    |          }| 
                    |	||||           |                                 |                     d          }|                     |d           d S )Nzparam-values(r=   =zending-parenthesis))r   rB   rC   rD   r	   r   rE   r   rF   r   r:   rG   rH   )r   r   r8   r   r9   r"   r%   rK   rL   rM   rN   rO   param_section_ends                r   r    z(SharedExampleDocumenter._document_params   sa   //??  444 	 	HCKK$$$(88==L''))),,T8<<L .""<000"++---sSy))) J 4"]..s33
NN<hjIIIHHJJJJ)99:NOO0#66666r   c                 \   |                     d          }|                     |d           |j        }t          |          D ]\  }}	|                     |          }
|
j                                         |                    d|z             |                     ||          }|r.|
                    |           |
j                                         | 	                    |
|	|||           |
                                 |                     d          }|                     |d           d S )Nzlist-section[z[%s]zending-bracketz],)r   rB   member	enumerater	   r   rD   rE   r   r:   rG   rH   )r   r   r8   r   r9   r"   list_sectionrO   indexrL   rM   rN   list_section_ends                r   r1   z&SharedExampleDocumenter._document_list   s,   ..~>>  s333\
#E** 		 		JE3'77>>L'')))KK''',,T8<<L .""<000"++---NN<hjIIIHHJJJJ'778HII/66666r   c                 V    t          |          }|                    d| d           d S )N'z',)r   r   )r   r   r8   r9   
safe_values        r   r7   z%SharedExampleDocumenter._document_str   s5     %U++
(*((()))))r   c                 P    |                     dt          |          z             d S )Nz%s,)r   str)r   r   r8   r9   s       r   r4   z(SharedExampleDocumenter._document_number   s%    ec%jj()))))r   c                    t          |                                          }t          |d                   }t          dt	          |                    D ]}|dt          ||                   z   z  }|                    d|z             d S )Nr      z, zdatetime(%s),)r   	timetuplera   rangelenr   )r   r   r8   r9   datetime_tupledatetime_stris          r   r6   z*SharedExampleDocumenter._document_datetime   s    (//99;;>!,--q#n--.. 	: 	:AD3~a'8#9#999LLo455555r   c                 z    t          j        ddd                    |                    }|r||v rd||         z   S dS )Nz^\. z# )resubjoin)r   r9   r   rK   s       r   rE   z$SharedExampleDocumenter._get_comment   sC    fVR// 	x(3-''2r   c                     |                     |           |j                                         |j                                         d S N)r   r	   indent)r   r   starts      r   rB   z+SharedExampleDocumenter._start_nested_value   sB    er   c                     |j                                          |j                                          |j                                          |                    |           d S rp   )r	   dedentr   r   )r   r   ends      r   rH   z)SharedExampleDocumenter._end_nested_value   sV       cr   N)F)__name__
__module____qualname__r   r   r   r:   r*   r    r1   r7   r4   r6   rE   rB   rH    r   r   r   r      s        M M M*. . .". . ."5 5 54 @E( ( ( (:7 7 7,7 7 7"* * ** * *6 6 6    
    r   r   c                     |                      d          }|j                                         |j                            d           t	                      }|D ]4}|                    ||                     |d                   ||           5dS )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B))+++  ,,,(**J" 
 
**%55gdmDD!+	 	+ 	
 	
 	
 	

 
r   )r2   rl   botocore.docs.utilsr   botocore.utilsr   r   r   ry   r   r   <module>r      s     				 / / / / / / * * * * * *u u u u u u u up
 
 
 
 
r   