
    g                     ~    d dl Z d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ  G d	 d
e      Zy)    N)DataNotFoundError)ServiceDocumenter)DocumentStructure)ServiceContext)Boto3ClientDocumenter)ResourceDocumenter)ServiceResourceDocumenterc                        e Zd Zej                  j                  ej                  j                  ej                        d      Z	 fdZ
d Zd Zd Zd Zd Zd Z xZS )	r   examplesc                 >   t         t        |   ||j                         || _        | j                  j                  |      | _        d | _        | j                  | j                  j                         v r | j                  j                  |      | _        g d| _        y )N)service_namesession)titletable-of-contentsclient
paginatorswaitersservice-resource	resourcesr   )superr   __init___session_boto3_sessionr   _client_service_resource_service_nameget_available_resourcesresourcesections)selfr   r   	__class__s      %lib/third_party/boto3/docs/service.pyr   zServiceDocumenter.__init__   s    /% $$	 	0 	
 &**11,?!%!4!4!L!L!NN%)%8%8%A%A,%OD"	
    c                 ~   t        | j                  | j                  d      }| j                  |j	                  d             | j                  |j	                  d             | j                  |j	                  d             | j                  |j	                  d             | j                  |j	                  d             | j                  r@| j                  |j	                  d             | j                  |j	                  d	             | j                  |j	                  d
             |j                         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   r   get_sectiontable_of_contents
client_apipaginator_api
waiter_apir   _document_service_resource_document_resources_document_examplesflush_structure)r    doc_structures     r"   document_servicez"ServiceDocumenter.document_service5   s   
 *dmm 	

=,,W56}889LMN11(;<=44\BC11)<=!!++))*<=?$$]%>%>{%KL 9 9* EF,,..r#   c                     d }	 | j                  | j                        }t        | j                  |      j                  |       y # t        $ r Y 1w xY wN)get_examplesr   r   r   r   document_client)r    sectionr   s      r"   r*   zServiceDocumenter.client_apiJ   sQ    	((););<H 	dllH5EEgN ! 		s   A 	AAc                 b    t        | j                  | j                        j                  |       y r4   )r	   r   r   document_resource)r    r7   s     r"   r-   z,ServiceDocumenter._document_service_resourceS   s'    !""DMM	33D3D4r#   c                    d}| j                   j                  d      }|j                  | j                  d      }| j                  j
                  j                  j
                  j                  }|d   D ]  }|d   |   }| j                  j                  j                  ||t        | j                  |d   |d             }|j
                  j                  j                  }	g }
|	D ]  }|
j                  |         ||
d| j                  i}t!        || j                         j#                  |j%                  |j
                  j                  j&                                y )Nfoodata_loaderzresources-1r   )r   resource_json_definitionsservice_modelservice_waiter_model)resource_namesingle_resource_json_definitionservice_contextr   )r   get_componentload_service_modelr   r   metar   r>   r   resource_factoryload_from_definitionr   resource_modelidentifiersappendr   r   r9   add_new_sectionname)r    r7   temp_identifier_valueloaderjson_resource_modelr>   r@   rH   resource_clsrI   args_r   s                r"   r.   z%ServiceDocumenter._document_resourcesX   sH    %,,];$77/..33::??MM0=M0=mLN..??$$"/4B$2%)%7%72E'3)&3-1% % 
  '++::FFKD 12 !#T?$,,?H$--)):):++HMM,H,H,M,MN*P) >r#   c                     t         j                  j                  t         j                  j                  | j                  | j
                  dz               S )Nz.rst)ospathrealpathjoinEXAMPLE_PATHr   )r    s    r"   _get_example_filez#ServiceDocumenter._get_example_fileu   s?    wwGGLL**++f467 	7r#   c                    | j                         }t        j                  j                  |      r|j                  j                  d       |j                  j                          |j                  d       |j                  j                          |j                  j                          t        |d      5 }|j                  |j                                d d d        y y # 1 sw Y   y xY w)NExamplesz'.. contents::
    :local:
    :depth: 1r)
rY   rT   rU   isfilestyleh2new_linewriteopenread)r    r7   examples_filefs       r"   r/   z$ServiceDocumenter._document_examplesz   s    ..077>>-(MMZ(MM""$MMEFMM""$MM""$mS)Qaffh' *) ) *)s   6 C  C))__name__
__module____qualname__rT   rU   rW   dirnameboto3__file__rX   r   r2   r*   r-   r.   rY   r/   __classcell__)r!   s   @r"   r   r      sM    77<< ?LL
./*O
P:7
	(r#   r   )rT   rj   botocore.exceptionsr   botocore.docs.servicer   BaseServiceDocumenterbotocore.docs.bcdoc.restdocr   boto3.utilsr   boto3.docs.clientr   boto3.docs.resourcer   r	    r#   r"   <module>ru      s1    
  1 L 9 & 3 2 9i(- i(r#   