o
    Th`!                     @   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                    sf   t  j||j|d || _| j|| _d | _| j| j v r&| j	|| _g d| _
|| _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_nameget_available_resourcesresourcesections_root_docs_path_USER_GUIDE_LINK)selfr
   r   r   	__class__ R/home/air/segue/gpt/backup/venv/lib/python3.10/site-packages/boto3/docs/service.pyr      s   
	zServiceDocumenter.__init__c                 C   s   t | j| jdd}| |d | |d | |d | |d | jr4| 	|d | 
|d |d	}| | | S )
ziDocuments an entire service.

        :returns: The reStructured text of the documented service.
        html)section_namestargetr   r   r   r   r   r	   r   )r   r   r   r   get_section
client_apipaginator_api
waiter_apir   resource_section_document_examplesclient_context_paramsflush_structure)r   doc_structurecontext_params_sectionr"   r"   r#   document_service9   s   


z"ServiceDocumenter.document_servicec                 C   sB   d }z|  | j}W n	 ty   Y nw t| j| j|| d S )N)get_examplesr   r   r   r   r   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 )N	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writeexternal_linkr   toctree_document_service_resource_document_resources)r   r4   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r7d}tj| j| j |  }||d |j| j d| d	 d S )
Nzservice-resourcer$   r&   
breadcrumb../../z / Resource / ServiceResourceindex//index)r   add_new_sectionr8   refr   r!   __name__r   r;   r   r   r   r   document_resourcemetaresource_modelnameospathjoinlowerwrite_to_filetocitem)r   r4   service_resource_docbreadcrumb_sectionresource_nameservice_resource_dir_pathr"   r"   r#   r>   n   s,   


z,ServiceDocumenter._document_service_resourcec              
   C   sX  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 qd S )Nfoodata_loaderzresources-1r   )r
   resource_json_definitionsservice_modelservice_waiter_model)rU   single_resource_json_definitionservice_contextr   r$   r@   rA   rB   z / Resource / rC   rD   rE   )!r   get_componentload_service_modelr   r   rJ   r   rZ   r   resource_factoryload_from_definitionr   rK   identifiersappendr   rL   rP   r   rF   r8   rG   r!   rH   r;   r   r   rI   rM   rN   rO   rQ   rR   )r   r4   temp_identifier_valueloaderjson_resource_modelrZ   rU   rK   resource_clsrb   args_r   resource_docrT   rV   r"   r"   r#   r?      sf   


z%ServiceDocumenter._document_resourcesc                 C   s   t jt j| j| jd S )Nz.rst)rM   rN   realpathrO   EXAMPLE_PATHr   )r   r"   r"   r#   _get_example_file   s   z#ServiceDocumenter._get_example_filec                 C   sj   |   }tj|r3|jd |j  t|}||	  W d    d S 1 s,w   Y  d S d S )NExamples)
rm   rM   rN   isfiler8   r9   r:   openr;   read)r   r4   examples_filefr"   r"   r#   r,      s   

"z$ServiceDocumenter._document_examples)rH   
__module____qualname__rM   rN   rO   dirnameboto3__file__rl   r   r1   r(   r+   r>   r?   rm   r,   __classcell__r"   r"   r    r#   r      s    7r   )rM   botocore.docs.bcdoc.restdocr   botocore.docs.servicer   BaseServiceDocumenterbotocore.exceptionsr   rw   boto3.docs.clientr   boto3.docs.resourcer   r   boto3.utilsr   r"   r"   r"   r#   <module>   s   