
    Pe"                     ^    d dl mZ d dlmZ  G d de      Z G d de      Z G d de      Zy	)
    )ShapeDocumenter)
py_defaultc                   j    e Zd Z	 ddZd Z	 ddZ	 ddZ	 ddZ	 ddZ	 ddZ	d	 Z
dd
ZddZd Zy)BaseExampleDocumenterNc                    g }|j                   j                          |j                   j                          ||j                  |       | j	                  |||||       |j                  d      }|j                   j                          y)a]  Generates an example based on a shape

        :param section: The section to write the documentation to.

        :param shape: The shape of the operation.

        :param prefix: Anything to be included before the example

        :type include: Dictionary where keys are parameter names and
            values are the shapes of the parameter names.
        :param include: The parameter shapes to include in the documentation.

        :type exclude: List of the names of the parameters to exclude.
        :param exclude: The names of the parameters to exclude from
            documentation.
        N)sectionshapehistoryincludeexcludezfinal-blank-line)stylenew_linestart_codeblockwritetraverse_and_document_shapeadd_new_section)selfr   r	   prefixr   r   r
   final_blank_line_sections           7/usr/lib/python3/dist-packages/botocore/docs/example.pydocument_examplez&BaseExampleDocumenter.document_example   s    &  %%'MM&!(( 	) 	
 $+#:#:;M#N  &&//1    c                 &    |j                  d       y )Nz{'... recursive ...'})r   )r   r   r	   kwargss       r   document_recursive_shapez.BaseExampleDocumenter.document_recursive_shape4   s    /0r   c                     | j                  |      }|t        |j                        }| j                  j	                  d      |k(  rd}|j                  |       y )Nstreaming_shapezStreamingBody())_get_special_py_defaultr   	type_name_contextgetr   )r   r   r	   r
   r   r   r   py_types           r   document_shape_defaultz,BaseExampleDocumenter.document_shape_default7   sP     ..u5? 1G==./58'Ggr   c                    d|j                   v ret        |j                   d         D ]I  \  }}|j                  d|z         |t        |j                   d         dz
  k  s9|j                  d       K y | j	                  |||       y )Nenum'%s'   |)metadata	enumerater   lenr#   )	r   r   r	   r
   r   r   r   ir%   s	            r   document_shape_type_stringz0BaseExampleDocumenter.document_shape_type_stringB   s|     U^^#$U^^F%;< '4ho.s5>>&12Q66MM#&'
 ''@r   c                 R   |j                   }|j                  d      }| j                  |d       |j                  dd|j                  i      }	| j	                  |	||       |j                  d      }
|
j                  d       |j                  d	      }| j                  |d
       y )Nz
list-value[memberr	   contextr   r	   r
   ending-comma,ending-bracket])r0   r   _start_nested_paramnamer   r   _end_nested_param)r   r   r	   r
   r   r   r   param_shapelist_sectionparam_sectionending_comma_sectionending_bracket_sections               r   document_shape_type_listz.BaseExampleDocumenter.document_shape_type_listM   s     ll..|<  s3$44w(8(89 5 
 	((!g 	) 	
  ,;;NK""3'!-!=!=>N!O5s;r   c                 p   |j                   s|j                  d       y |j                  d      }| j                  |d       | j	                  |j                   |      }t        |      D ]  \  }}	|r|	|v r|j                  |	      }
|
j                  d|	z         ||	   }|
j                  dd|j                  i      }| j                  ||||	       |t        |      d	z
  k  s}|
j                  d
      }|j                  d       |j                  j                           | j                  |dd       y )Nz{}structure-value{z'%s': member-valuer	   r1   r   r	   r
   r9   r'   r4   r5   })membersr   r   r8   _add_members_to_shaper*   r9   r   r+   r   r   _end_structure)r   r   r	   r
   r   r   r   input_membersr,   paramr=   r;   param_value_sectionr>   s                 r   document_shape_type_structurez3BaseExampleDocumenter.document_shape_type_structure^   sI    }}MM$))*;<  #.225=='J!-0 	6HAu5G+#33E:M
U 23'.K"/"?"?+2B2B(C #@ # ,,+!	 -  3}%))'4'D'D"($ %**3/$**335)	6* 	GS#.r   c                    |j                  d      }| j                  |d       |j                  }|j                  dd|j                  j                  i      }	|	j                  d       |j                  dd|j                  i      }
| j                  |
||       |j                  d	      }| j                  |d
       y )Nz	map-valuerC   keyr	   r1   z
'string': valuer3   r6   rF   )r   r8   rP   rO   r9   r   r   r:   )r   r   r	   r
   r   r   r   map_sectionvalue_shapekey_sectionvalue_sectionend_bracket_sections               r   document_shape_type_mapz-BaseExampleDocumenter.document_shape_type_map   s     --k:  c2kk!11GUYY^^4 2 
 	.)#33g{'7'78 4 
 	((!g 	) 	
 *99:JK2C8r   c                 V    |r&|j                         }|D ]  }|||j                  <    |S N)copyr9   )r   rG   r   rK   s       r   rH   z+BaseExampleDocumenter._add_members_to_shape   s2    llnG  ,&+

#,r   c                     ||j                  |       |j                  j                          |j                  j                          |j                  j                          y rX   )r   r   indentr   )r   r   starts      r   r8   z)BaseExampleDocumenter._start_nested_param   sD    MM%  r   c                     |j                   j                          |j                   j                          |j                   j                          ||j                  |       y y rX   )r   dedentr   r   )r   r   ends      r   r:   z'BaseExampleDocumenter._end_nested_param   sH     ?MM# r   c                     |j                   s6|j                          |j                  ||z          | j                  |       y |j	                  d      }| j                  ||       y )Nr6   )available_sections
clear_textr   r:   r   )r   r   r\   r_   rU   s        r   rI   z$BaseExampleDocumenter._end_structure   sZ     )) MM%#+&""7+")"9"9:J"K""#6<r   )NNNNNrX   )__name__
__module____qualname__r   r   r#   r-   r@   rM   rV   rH   r8   r:   rI    r   r   r   r      s]    AE 2D1 >B	 >B	A >B<$ >B!/H >B9&!
=r   r   c                       e Zd ZdZd Zy)ResponseExampleDocumenterzresponse-examplec                     |j                  d        | j                  |||fi | |j                  d      }|j                  d       y )NzEventStream(zevent-stream-end))r   rM   r   )r   r   r	   r
   r   end_sections         r    document_shape_type_event_streamz:ResponseExampleDocumenter.document_shape_type_event_stream   sH     	n%***7E7MfM--.@A#r   N)rd   re   rf   
EVENT_NAMErm   rg   r   r   ri   ri      s    #Jr   ri   c                       e Zd ZdZ	 ddZy)RequestExampleDocumenterzrequest-exampleNc                    d}d}d}	d}
t        |      dk  rd}d}	d}
d	}|j                  d
      }| j                  ||	       | j                  |j                  |      }t        |      D ]  \  }}|r||v r|j                  |      }|j                  ||z         |j                  |       ||   }|j                  dd|j                  i      }| j                  ||||       |t        |      dz
  k  s|j                  d      }|j                  d       |j                  j                           | j                  ||	|
       y )Nr&   z: rC   rF   r'   =(rk   z%srB   rD   r	   r1   rE   r4   r5   )r+   r   r8   rH   rG   r*   r   r9   r   r   r   rI   )r   r   r	   r
   r   r   r   param_formatoperatorr\   r_   rJ   r,   rK   r=   r;   rL   r>   s                     r   rM   z6RequestExampleDocumenter.document_shape_type_structure   su     w<1HECL))*;<  %0225=='J!-0 	6HAu5G+#33E:Mu 45)'.K"/"?"?+2B2B(C #@ # ,,+!	 -  3}%))'4'D'D"($ %**3/$**335+	6, 	GUC0r   rc   )rd   re   rf   rn   rM   rg   r   r   rp   rp      s    "J >B'1r   rp   N)botocore.docs.shaper   botocore.docs.utilsr   r   ri   rp   rg   r   r   <module>rx      s6    0 *b=O b=J	 5 	*14 *1r   