
    j+&                         d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ dZ	 ej
        d          ZdZ e j        d          Zd	d
dddddd
dddddZddddZ G d d          Z G d de          ZdS )    N)OrderedDict)DocStringParser)	ReSTStylez&https://docs.aws.amazon.com/index.htmlzX`AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/[a-z0-9-.]*/[a-zA-Z]*>`_z

    **{}**
    ::

        # This section is too large to render.
        # Please see the AWS API Documentation linked below.

    {}
    bcdocszResponse Syntaxi  )name
line_limitzResponse Structurei  zRequest Syntax
Parameters)zresponse-exampledescriptionzrequest-examplezrequest-params      )z
client-apizpaginator-apiz
waiter-apic                   X    e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd ZdS )ReSTDocumentmanc                     t          |           | _        || _        t          |           | _        d| _        d| _        i | _        i | _        g | _	        d | _
        d S )NTF)r   styletargetr   parser	keep_datado_translationtranslation_maphrefs_writes_last_doc_string)selfr   s     \/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/botocore/docs/bcdoc/restdoc.py__init__zReSTDocument.__init__3   sX    t__
%d++#!
 $    c                 T    | j         r|| j                            |           d S d S d S N)r   r   appendr   ss     r   _writezReSTDocument._write>   s:    > 	#amL"""""	# 	#mmr   c                 0    |                      |           dS )z2
        Write content into the document.
        N)r#   r   contents     r   writezReSTDocument.writeB   s     	Gr   c                 h    |                      | j                                         | d           dS )z-
        Write content on a newline.
        
N)r#   r   spacesr%   s     r   writelnzReSTDocument.writelnH   s8     	tz((**7G77788888r   c                     | j         d         S )zn
        Returns the last content written to the document without
        removing it from the stack.
        r   r   s    r   
peek_writezReSTDocument.peek_writeN   s    
 |Br   c                 h    t          | j                  dk    r| j                                        ndS )zL
        Removes and returns the last content written to the stack.
        r   N)lenr   popr/   s    r   	pop_writezReSTDocument.pop_writeU   s1     &)%6%6%:%:t|!!!Dr   c                 :    | j                             |           dS )z2
        Places new content on the stack.
        N)r   r    r!   s     r   
push_writezReSTDocument.push_write[   s      	Ar   c                    | j         rS| j                                         | j                                         D ] \  }}| j                            ||           !d                    | j                                      d          S )zJ
        Returns the current content of the document as a string.
         utf-8)r   r   new_paragraphitemslink_target_definitionjoinr   encode)r   refnamelinks      r   getvaluezReSTDocument.getvaluea   s     : 	AJ$$&&&!%!1!1!3!3 A A
11'4@@@@wwt|$$++G444r   c                        fd|D             S )Nc                 F    g | ]}j                             ||          S  )r   get).0wr   s     r   
<listcomp>z0ReSTDocument.translate_words.<locals>.<listcomp>l   s,    >>>1$((A..>>>r   rD   )r   wordss   ` r   translate_wordszReSTDocument.translate_wordsk   s    >>>>>>>>r   c                 J    |r| j         r|                     |           d S d S d S r   )r   r#   )r   datas     r   handle_datazReSTDocument.handle_datan   s?     	DN 	KK	 	 	 	r   c                 f   |r	 t          | j                  }| j                            |           | j                                         t          | j                  }||f| _        d S # t          $ r: t                              dd           t                              |           Y d S w xY wd S )NzError parsing doc stringT)exc_info)	r2   r   r   feedcloser   	ExceptionLOGdebug)r   
doc_stringstartends       r   include_doc_stringzReSTDocument.include_doc_stringr   s     		&&DL))  ,,,!!###$,'').%%% & & &		4t	DDD		*%%%%%%&		& 		&s   A$A* *A B.-B.c                 @    | j         | j         \  }}| j        ||= d S d S r   )r   r   )r   rV   rW   s      r   remove_last_doc_stringz#ReSTDocument.remove_last_doc_string~   s3     ,.JE3U3Y''' -,r   N)r   )__name__
__module____qualname__r   r#   r'   r+   r0   r4   r6   rA   rJ   rM   rX   rZ   rD   r   r   r   r   2   s        	% 	% 	% 	%# # #  9 9 9     E E E  5 5 5? ? ?  
& 
& 
&( ( ( ( (r   r   c                        e Zd Zd fd	Zed             Zed             Zej        d             Zed             Zed             Z	d	 Z
dd
Zd Zd Zd ZddZd Zd Zd Zd Zd Z xZS )DocumentStructureNr   c                     t                                          |           || _        t                      | _        | j        g| _        i | _        ||| _        ||                     |           dS dS )a5  Provides a Hierarichial structure to a ReSTDocument

        You can write to it similiar to as you can to a ReSTDocument but
        has an innate structure for more orginaztion and abstraction.

        :param name: The name of the document
        :param section_names: A list of sections to be included
            in the document.
        :param target: The target documentation of the Document structure
        :param context: A dictionary of data to store with the strucuture. These
            are only stored per section not the entire structure.
        )r   N)superr   _namer   
_structure_path_context_generate_structure)r   r   section_namesr   context	__class__s        r   r   zDocumentStructure.__init__   sy     	'''
%--j\
#DM$$$]33333 %$r   c                     | j         S )z"The name of the document structure)rb   r/   s    r   r   zDocumentStructure.name   s     zr   c                     | j         S )zv
        A list of where to find a particular document structure in the
        overlying document structure.
        rd   r/   s    r   pathzDocumentStructure.path   s     zr   c                     || _         d S r   rl   )r   values     r   rm   zDocumentStructure.path   s    


r   c                 *    t          | j                  S r   )listrc   r/   s    r   available_sectionsz$DocumentStructure.available_sections   s    DO$$$r   c                     | j         S r   )re   r/   s    r   rh   zDocumentStructure.context   s
    }r   c                 :    |D ]}|                      |           d S r   )add_new_section)r   rg   section_names      r   rf   z%DocumentStructure._generate_structure   s2    ) 	/ 	/L  ....	/ 	/r   c                     |                      || j        |          }| j        |gz   |_        | j        j        |j        _        | j        |_        | j        |_        || j        |<   |S )a  Adds a new section to the current document structure

        This document structure will be considered a section to the
        current document structure but will in itself be an entirely
        new document structure that can be written to and have sections
        as well

        :param name: The name of the section.
        :param context: A dictionary of data to store with the strucuture. These
            are only stored per section not the entire structure.
        :rtype: DocumentStructure
        :returns: A new document structure to add to but lives as a section
            to the document structure it was instantiated from.
        )r   r   rh   )ri   r   rm   r   indentationr   r   rc   )r   r   rh   sections       r   ru   z!DocumentStructure.add_new_section   sk      ..dk7 ! 
 
 yD6)$(J$:!"&"6
 'r   c                     | j         |         S )zRetrieve a sectionrc   r   r   s     r   get_sectionzDocumentStructure.get_section   s    t$$r   c                     || j         v S r   r{   r|   s     r   has_sectionzDocumentStructure.has_section   s    t&&r   c                     | j         |= dS )zDelete a sectionNr{   r|   s     r   delete_sectionz DocumentStructure.delete_section   s    OD!!!r   c                    t          | j                  }|dk    r[| j        rS| j                                         | j                                        D ] \  }}| j                            ||           !n+|t                              | j        d                   k    rd}| 	                                }| j
                                        D ]w\  }}t                              |                                          }|r*|                    d           d                                n|}||                    |          z  }xt          |                                          }	t$                              | j                  }
||                                nt(          }|
r?|	|
d         k    r3t*                              |
d         |                                          }|S )zFlushes a doc structure to a ReSTructed string

        The document is flushed out in a DFS style where sections and their
        subsections' values are added to the string as they are visited.
           Nr   z

r   r   )r2   rm   r   r   r:   r;   r<   SECTION_METHOD_PATH_DEPTHrE   rA   rc   DOCUMENTATION_LINK_REGEXsearchdecodegroupr>   flush_structure
splitlinesSECTION_LINE_LIMIT_CONFIGr   DEFAULT_AWS_DOCS_LINKLARGE_SECTION_MESSAGEformat)r   	docs_linkpath_lengthr?   r@   ro   r   ry   match
line_countsection_configaws_docs_links               r   r   z!DocumentStructure.flush_structure   s    $)nn!z E
((***%)Z%5%5%7%7 E EMGTJ55gtDDDD599$)A,GGGGI!_2244 	8 	8MD' -33ELLNNCCE49H5;;q>>'''..000y  W,,Y777EE ))++,,
266tyAA $ & 	
  	j>,+GGG)00v& fhh  r   c                 \    d                     | j                                      d          S )Nr8   r9   )r=   r   r>   r/   s    r   rA   zDocumentStructure.getvalue
  s$    wwt|$$++G444r   c                 ,    t                      | _        d S r   )r   rc   r/   s    r   remove_all_sectionsz%DocumentStructure.remove_all_sections  s    %--r   c                     g | _         d S r   r.   r/   s    r   
clear_textzDocumentStructure.clear_text  s    r   c                 d    |                      d          }|j                            |           |S )Ntitle)ru   r   h1)r   r   title_sections      r   add_title_sectionz#DocumentStructure.add_title_section  s2    ,,W55u%%%r   c                 R   t           j                            |          st          j        |           t           j                            || d          }t          |d          5 }|                    |                                            d d d            d S # 1 swxY w Y   d S )Nz.rstwb)osrm   existsmakedirsr=   openr'   r   )r   	full_path	file_namesub_resource_file_pathfs        r   write_to_filezDocumentStructure.write_to_file  s    w~~i(( 	#K	"""!#iI9K9K9K!L!L($// 	,1GGD((**+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   '(BB #B )Nr   Nr   )r[   r\   r]   r   propertyr   rm   setterrr   rh   rf   ru   r}   r   r   r   rA   r   r   r   r   __classcell__)ri   s   @r   r_   r_      sv       4 4 4 4 4 4.   X   X 
[  [ % % X%   X/ / /   6% % %' ' '" " "( ( ( (T5 5 5( ( (    
, , , , , , ,r   r_   )loggingr   rebotocore.compatr   #botocore.docs.bcdoc.docstringparserr   botocore.docs.bcdoc.styler   r   compiler   r   	getLoggerrS   r   r   r   r_   rD   r   r   <module>r      sT    				 				 ' ' ' ' ' ' ? ? ? ? ? ? / / / / / /@ %2:I  	  g!!!2$GG0EE 0EE+4@@	     P( P( P( P( P( P( P( P(fX, X, X, X, X, X, X, X, X, X,r   