U
    N8cN                     @   s   d dl mZ G dd dZdS )    )is_json_value_headerc                   @   s<   e Zd ZdZdddZdddZdd	 Zd
d Zdd ZdS )ShapeDocumenter Nc                 C   s.   || _ || _|| _|| _|d kr*di i| _d S )Nspecial_shape_types)_service_name_operation_name_event_emitter_context)selfZservice_nameZoperation_nameZevent_emittercontext r   7/tmp/pip-unpacked-wheel-ozje0y8b/botocore/docs/shape.py__init__   s    zShapeDocumenter.__init__Fc              
   C   s  |j }t|di drd}|j|kr8| j|||d n||j t|dk}	t|drd|jrdd}t| d| | j	|||||||	|d	 |	r| j
jd
| j d| j d| j d| |d t|dk}
|
r| j
jd
| j d| j d| j d|d |  dS )a  Traverses and documents a shape

        Will take a self class and call its appropriate methods as a shape
        is traversed.

        :param section: The section to document.

        :param history: A list of the names of the shapes that have been
            traversed.

        :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.

        :param name: The name of the shape.

        :param is_required: If the shape is a required member.
        ZserializationZeventstreamZevent_stream)name   is_document_typedocumentZdocument_shape_type_)historyr   includeexcludeis_top_level_paramis_requiredzdocs..)section   z.complete-sectionN)	type_namegetattrgetr   Zdocument_recursive_shapeappendlenhasattrr   Zdocument_shape_defaultr   emit
EVENT_NAMEr   r   pop)r
   r   shaper   r   r   r   r   Z
param_typer   Zat_overlying_method_sectionr   r   r   traverse_and_document_shape#   sF     
 z+ShapeDocumenter.traverse_and_document_shapec                 C   s   dddddd}|  ||S )Nz({...}|[...]|123|123.4|'string'|True|Nonezb'bytes'|filezStreamingBody()zEventStream()document_typejsonvalue_headerZstreaming_input_shapeZstreaming_output_shapeZeventstream_output_shape_get_value_for_special_type)r
   r$   Zspecial_defaultsr   r   r   _get_special_py_defaulth   s    z'ShapeDocumenter._get_special_py_defaultc                 C   s   dddddd}|  ||S )Nz:ref:`document<document>`zJSON serializablez"bytes or seekable file-like objectz:class:`.StreamingBody`z:class:`.EventStream`r&   r)   )r
   r$   Zspecial_type_namesr   r   r   _get_special_py_type_namer   s    z)ShapeDocumenter._get_special_py_type_namec                 C   s`   t |r|d S t|dr(|jr(|d S | jd  D ]$\}}||kr6||kr6||   S q6d S )Nr(   r   r'   r   )r   r    r   r	   items)r
   r$   Zspecial_type_mapZspecial_typeZmarked_shaper   r   r   r*   |   s    z+ShapeDocumenter._get_value_for_special_type)N)NNNF)	__name__
__module____qualname__r"   r   r%   r+   r,   r*   r   r   r   r   r      s    
    
E

r   N)Zbotocore.utilsr   r   r   r   r   r   <module>   s   