o
    VÇòfò#  ã                   @   sB   d dl Z d dlZd dlmZ d dlmZ G dd„ dƒZdd„ ZdS )é    N)Úescape_controls)Úparse_timestampc                   @   sx   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Z		dd
d„Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚSharedExampleDocumenterc                 C   sJ   |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_model© r   ú\/home/ubuntu/oakencloud.com/venv/lib/python3.10/site-packages/botocore/docs/sharedexample.pyÚdocument_shared_example   s   


ÿz/SharedExampleDocumenter.document_shared_examplec           
      C   sœ   |  d¡}|j ¡  |d ur| |¡ | 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_sectionr   r   r   r   *   s   









z&SharedExampleDocumenter.document_inputc                 C   sŽ   |  d¡}|j ¡  | d¡ |j ¡  |j ¡  | di ¡}ddi|d< | d¡}|r1| 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"   r   r   r   r   ;   s   







z'SharedExampleDocumenter.document_outputc                 C   s   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   r   r   r   Ú	_documentL   s   

z!SharedExampleDocumenter._documentFc                 C   sø   |  d¡}|  |d¡ | ¡ D ]V\}}	| d|› ¡ |  |¡}
|
j ¡  |  ||¡}|r7|
 |¡ |
j ¡  |
 d|› d¡ d }|rX|jdkrP|j	 
|¡}n|jdkrX|j}|  |
|	|||¡ | ¡  q|  d¡}|  |d	¡ |sz| d
¡ d S d S )Nz
dict-valueÚ{Ú.ú'z': Ú	structureÚmapzending-braceÚ}ú,)r   Ú_start_nested_valueÚitemsÚappendr   r
   Ú_get_commentr   r/   Úmembersr	   r2   r4   ÚpopÚ_end_nested_value)r   r   r2   r   r3   r   Ú	top_levelÚdict_sectionÚkeyÚvalÚitem_sectionÚitem_commentÚ
item_shapeÚdict_section_endr   r   r   r%   e   s0   








ÿz&SharedExampleDocumenter._document_dictc                 C   sÆ   |  d¡}|  |d¡ | ¡ D ]F\}}| d|› ¡ |  |¡}	|	j ¡  |  ||¡}
|
r7|	 |
¡ |	j ¡  |	 |d ¡ d }|rH|j 	|¡}|  
|	||||¡ | ¡  q|  d¡}|  |d¡ d S )Nzparam-valuesú(r6   ú=zending-parenthesisú))r   r<   r=   r>   r   r
   r?   r   r@   r	   r4   rA   rB   )r   r   r2   r   r3   r   r!   rE   rF   rG   rH   rI   Úparam_section_endr   r   r   r   ‚   s$   






z(SharedExampleDocumenter._document_paramsc                 C   s¬   |  d¡}|  |d¡ |j}t|ƒD ]6\}}	|  |¡}
|
j ¡  | d|› d¡ |  ||¡}|r;|
 |¡ |
j ¡  |  	|
|	|||¡ | 
¡  q|  d¡}|  |d¡ d S )Nzlist-sectionú[ú]zending-bracketz],)r   r<   ÚmemberÚ	enumerater   r
   r>   r?   r   r4   rA   rB   )r   r   r2   r   r3   r   Úlist_sectionrI   ÚindexrF   rG   rH   Úlist_section_endr   r   r   r+   ˜   s   






z&SharedExampleDocumenter._document_listc                 C   s   t |ƒ}| d|› d¡ d S )Nr7   z',)r   r   )r   r   r2   r3   Ú
safe_valuer   r   r   r1   ©   s   z%SharedExampleDocumenter._document_strc                 C   s   |  t|ƒ› d¡ d S )Nr;   )r   Ústr)r   r   r2   r3   r   r   r   r.   ¯   s   z(SharedExampleDocumenter._document_numberc                 C   sV   t |ƒ ¡ }t|d ƒ}tdt|ƒƒD ]}|dt|| ƒ 7 }q| d|› d¡ d S )Nr   é   z, z	datetime(z),)r   Ú	timetuplerW   ÚrangeÚlenr   )r   r   r2   r3   Údatetime_tupleÚdatetime_strÚir   r   r   r0   ²   s
   z*SharedExampleDocumenter._document_datetimec                 C   s0   t  ddd |¡¡}|r||v rd||  S dS )Nz^\.Ú z# )ÚreÚsubÚjoin)r   r3   r   rE   r   r   r   r?   ¹   s   z$SharedExampleDocumenter._get_commentc                 C   s"   |  |¡ |j ¡  |j ¡  d S ©N)r   r   Úindent)r   r   Ústartr   r   r   r<   À   s   

z+SharedExampleDocumenter._start_nested_valuec                 C   s,   |j  ¡  |j  ¡  |j  ¡  | |¡ d S rc   )r   Údedentr
   r   )r   r   Úendr   r   r   rB   Å   s   


z)SharedExampleDocumenter._end_nested_valueN)F)Ú__name__Ú
__module__Ú__qualname__r   r   r   r4   r%   r   r+   r1   r.   r0   r?   r<   rB   r   r   r   r   r      s    
ÿr   c                 C   sP   |   d¡}|j ¡  |j d¡ tƒ }|D ]}|j||  |d ¡||d qd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   r   r   r   Údocument_shared_examplesÌ   s   

üÿrr   )r,   r`   Úbotocore.docs.utilsr   Úbotocore.utilsr   r   rr   r   r   r   r   Ú<module>   s    9