
    tni#                     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        X/var/www/html/gpu-tools/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                 8   |                     d          }|                     |d           |                                D ]\  }}	|                    d|            |                     |          }
|
j                                         |                     ||          }|r.|
                    |           |
j                                         |
                    d| d           d }|r8|j        dk    r|j	        
                    |          }n|j        dk    r|j        }|                     |
|	|||           |                                 |                     d          }|                     |d	           |s|                    d
           d S d S )Nz
dict-value{.'z': 	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	C		"""'77<<L''))),,T8<<L .""<000"++---|3|||,,, 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|            |                     |          }	|	j                                         |                     ||          }
|
r.|	                    |
           |	j                                         |	                    |dz              d }|r|j        	                    |          }| 
                    |	||||           |                                 |                     d          }|                     |d           d S )Nzparam-values(r=   =zending-parenthesis))r   rC   rD   rE   r	   r   rF   r   rG   r   r:   rH   rI   )r   r   r8   r   r9   r"   r%   rL   rM   rN   rO   rP   param_section_ends                r   r    z(SharedExampleDocumenter._document_params   sc   //??  444 	 	HCKK	C		"""(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| d           |                     ||          }|r.|
                    |           |
j                                         | 	                    |
|	|||           |
                                 |                     d          }|                     |d           d S )Nzlist-section[]zending-bracketz],)r   rC   member	enumerater	   r   rE   rF   r   r:   rH   rI   )r   r   r8   r   r9   r"   list_sectionrP   indexrM   rN   rO   list_section_ends                r   r1   z&SharedExampleDocumenter._document_list   s0   ..~>>  s333\
#E** 		 		JE3'77>>L'')))KKE%%%,,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 )Nr>   z',)r   r   )r   r   r8   r9   
safe_values        r   r7   z%SharedExampleDocumenter._document_str   s5     %U++
(*((()))))r   c                 P    |                     t          |           d           d S )NrB   )r   str)r   r   r8   r9   s       r   r4   z(SharedExampleDocumenter._document_number   s)    U&&&'''''r   c                    t          |                                          }t          |d                   }t          dt	          |                    D ]}|dt          ||                   z   z  }|                    d| d           d S )Nr      z, z	datetime(z),)r   	timetuplerb   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2,22233333r   c                 z    t          j        ddd                    |                    }|r||v rd||         z   S dS )Nz^\. z# )resubjoin)r   r9   r   rL   s       r   rF   z$SharedExampleDocumenter._get_comment   sC    fVR// 	x(3-''2r   c                     |                     |           |j                                         |j                                         d S N)r   r	   indent)r   r   starts      r   rC   z+SharedExampleDocumenter._start_nested_value   sB    er   c                     |j                                          |j                                          |j                                          |                    |           d S rq   )r	   dedentr   r   )r   r   ends      r   rI   z)SharedExampleDocumenter._end_nested_value   sV       cr   N)F)__name__
__module____qualname__r   r   r   r:   r*   r    r1   r7   r4   r6   rF   rC   rI    r   r   r   r      s        M M M*. . .". . ."5 5 54 @E( ( ( (:7 7 7,7 7 7"* * *( ( (4 4 4    
    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   rm   botocore.docs.utilsr   botocore.utilsr   r   r   rz   r   r   <module>r      s     				 / / / / / / * * * * * *u u u u u u u up
 
 
 
 
r   