U
    EZh`!                     @   sp   d dl Z d dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
 d dlmZmZ d dlmZ G dd	 d	eZdS )
    N)DocumentStructure)ServiceDocumenter)DataNotFoundError)Boto3ClientDocumenter)ResourceDocumenterServiceResourceDocumenter)ServiceContextc                       sl   e Zd ZejejejdZ	 fddZ
dd Zdd Zdd	 Zd
d Zdd Zdd Zdd Z  ZS )r   examplesc                    sp   t  j||j|d || _| j|| _d | _| j| j krL| j	|| _dddddddg| _
|| _d	| _d S )
N)service_namesessionroot_docs_pathtitleclient
paginatorswaiters	resourcesr	   context-paramszLhttps://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html)super__init___session_boto3_sessionr   _client_service_resource_service_nameZget_available_resourcesresourcesections_root_docs_path_USER_GUIDE_LINK)selfr
   r   r   	__class__ Y/home/aprabhat/apps/x.techxrdev.in/venv/lib/python3.8/site-packages/boto3/docs/service.pyr      s*    	zServiceDocumenter.__init__c                 C   s   t | j| jdd}| |d | |d | |d | |d | jrh| 	|d | 
|d |d	}| | | S )
ziDocuments an entire service.

        :returns: The reStructured text of the documented service.
        html)Zsection_namestargetr   r   r   r   r   r	   r   )r   r   r   r   Zget_section
client_apiZpaginator_apiZ
waiter_apir   resource_section_document_examplesZclient_context_paramsZflush_structure)r   Zdoc_structureZcontext_params_sectionr!   r!   r"   document_service9   s      

z"ServiceDocumenter.document_servicec                 C   sD   d }z|  | j}W n tk
r(   Y nX t| j| j|| d S )N)Zget_examplesr   r   r   r   r   Zdocument_client)r   sectionr	   r!   r!   r"   r%   M   s      zServiceDocumenter.client_apic                 C   s   |j d |j   |d |j jd| jd |d |j   |j   |d |j   |j   | | | | d S )NZ	ResourceszResources are available in boto3 via the ``resource`` method. For more detailed instructions and examples on the usage of resources, see the resources z
user guide)r   link.zThe available resources are:)	styleh2new_linewriteZexternal_linkr   Ztoctree_document_service_resource_document_resources)r   r)   r!   r!   r"   r&   X   s"    







z"ServiceDocumenter.resource_sectionc                 C   s   t ddd}|d}|j| jjjd| j  |d t	| j
| j| j| | j
jjj}|| jkrnd}tj| j| j |  }||d |j| j d| d	 d S )
Nzservice-resourcer#   r$   
breadcrumb../../z / Resource / ServiceResourceindex//index)r   add_new_sectionr,   refr   r    __name__r   r/   r   r   r   r   document_resourcemetaresource_modelnameospathjoinlowerwrite_to_filetocitem)r   r)   Zservice_resource_docbreadcrumb_sectionresource_nameservice_resource_dir_pathr!   r!   r"   r0   n   s6     
 

  
z,ServiceDocumenter._document_service_resourcec              
   C   sZ  d}| j d}|| jd}| jjjjj}|d D ]}|d | }| jj	j
||t| j|d |d dd}|jjj}	g }
|	D ]}|
| q~||
d| ji}|jjj }t|dd	}|d
}|j| jjjd| j  |d|jjj  t|| j | j||jjj tj| j| j | }||d |j | j d| d q4d S )NZfooZdata_loaderzresources-1r   )r
   Zresource_json_definitionsservice_modelZservice_waiter_model)rF   Zsingle_resource_json_definitionZservice_contextr   r#   r2   r3   r4   z / Resource / r5   r6   r7   )!r   Zget_componentZload_service_modelr   r   r<   r   rH   r   Zresource_factoryZload_from_definitionr   r=   identifiersappendr   r>   rB   r   r8   r,   r9   r    r:   r/   r   r   r;   r?   r@   rA   rC   rD   )r   r)   Ztemp_identifier_valueloaderZjson_resource_modelrH   rF   r=   Zresource_clsrI   args_r   Zresource_docrE   rG   r!   r!   r"   r1      sj     

 
  z%ServiceDocumenter._document_resourcesc                 C   s   t jt j| j| jd S )Nz.rst)r?   r@   realpathrA   EXAMPLE_PATHr   )r   r!   r!   r"   _get_example_file   s    z#ServiceDocumenter._get_example_filec              	   C   sP   |   }tj|rL|jd |j  t|}||	  W 5 Q R X d S )NZExamples)
rP   r?   r@   isfiler,   r-   r.   openr/   read)r   r)   Zexamples_filefr!   r!   r"   r'      s    

z$ServiceDocumenter._document_examples)r:   
__module____qualname__r?   r@   rA   dirnameboto3__file__rO   r   r(   r%   r&   r0   r1   rP   r'   __classcell__r!   r!   r   r"   r      s   7r   )r?   Zbotocore.docs.bcdoc.restdocr   Zbotocore.docs.servicer   ZBaseServiceDocumenterZbotocore.exceptionsr   rX   Zboto3.docs.clientr   Zboto3.docs.resourcer   r   Zboto3.utilsr   r!   r!   r!   r"   <module>   s   