
    %                         S SK r S SKrS SKrS SKJr  S SKJr  S SKJr  Sr	\R                  " S5      rSr\ R                  " S5      rS	S
S.SSS.SS
S.SSS.S.rSSSS.r " S S5      r " S S\5      rg)    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                   `    \ rS rSrSS jrS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)ReSTDocument2   c                     [        U 5      U l        Xl        [        U 5      U l        SU l        SU l        0 U l        0 U l        / U l	        S U l
        g )NTF)r   styletargetr   parser	keep_datado_translationtranslation_maphrefs_writes_last_doc_string)selfr   s     .lib/third_party/botocore/docs/bcdoc/restdoc.py__init__ReSTDocument.__init__3   sK    t_
%d+#!
 $    c                 f    U R                   (       a   Ub  U R                  R                  U5        g g g N)r   r   appendr   ss     r   _writeReSTDocument._write>   s&    >>amLL" ,>r   c                 &    U R                  U5        g)z"
Write content into the document.
N)r$   r   contents     r   writeReSTDocument.writeB   s     	Gr   c                 `    U R                  U R                  R                  5        U S35        g)z
Write content on a newline.

N)r$   r   spacesr'   s     r   writelnReSTDocument.writelnH   s)     	tzz((*+G9B78r   c                      U R                   S   $ )zV
Returns the last content written to the document without
removing it from the stack.
r   r   s    r   
peek_writeReSTDocument.peek_writeN   s    
 ||Br   c                 l    [        U R                  5      S:  a  U R                  R                  5       $ S$ )z<
Removes and returns the last content written to the stack.
r   N)lenr   popr3   s    r   	pop_writeReSTDocument.pop_writeU   s,     &)%6%:t||!DDr   c                 :    U R                   R                  U5        g)z"
Places new content on the stack.
N)r   r!   r"   s     r   
push_writeReSTDocument.push_write[   s     	Ar   c                 (   U R                   (       aX  U R                  R                  5         U R                   R                  5        H   u  pU R                  R	                  X5        M"     SR                  U R                  5      R                  S5      $ )z:
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   getvalueReSTDocument.getvaluea   sd     ::JJ$$&!%!1!1!3

11'@ "4wwt||$++G44r   c                 b    U Vs/ s H  o R                   R                  X"5      PM     sn$ s  snf r    )r   get)r   wordsws      r   translate_wordsReSTDocument.translate_wordsk   s)    8=>1$$((.>>>s   $,c                 Z    U(       a$  U R                   (       a  U R                  U5        g g g r    )r   r$   )r   datas     r   handle_dataReSTDocument.handle_datan   s    DNNKK #4r   c                 V   U(       ai   [        U R                  5      nU R                  R                  U5        U R                  R	                  5         [        U R                  5      nX#4U l        g g ! [         a,    [        R                  SSS9  [        R                  U5         g f = f)NzError parsing doc stringT)exc_info)	r7   r   r   feedcloser   	ExceptionLOGdebug)r   
doc_stringstartends       r   include_doc_stringReSTDocument.include_doc_stringr   s    &DLL)  ,!!#$,,').%   &		4t	D		*%&s   A'A2 23B('B(c                 X    U R                   b  U R                   u  pU R                  X2	 g g r    )r   r   )r   r\   r]   s      r   remove_last_doc_string#ReSTDocument.remove_last_doc_string~   s.      ,..JEUY' -r   )	r   r   r   r   r   r   r   r   r   N)man)__name__
__module____qualname____firstlineno__r   r$   r)   r.   r4   r9   r<   rH   rN   rR   r^   ra   __static_attributes__ r   r   r   r   2   s?    	%#9 E5?
&(r   r   c                      ^  \ rS rSrSU 4S jjr\S 5       r\S 5       r\R                  S 5       r\S 5       r	\S 5       r
S rSS	 jrS
 rS rSS jrS rS rS rS rS rSrU =r$ )DocumentStructure   c                    > [         TU ]  US9  Xl        [        5       U l        U R                  /U l        0 U l        Ub  X@l        Ub  U R                  U5        gg)a  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   DocumentStructure.__init__   s[     	'
%-jj\
#M$$$]3 %r   c                     U R                   $ )z"The name of the document structure)ro   r3   s    r   r   DocumentStructure.name   s     zzr   c                     U R                   $ )z^
A list of where to find a particular document structure in the
overlying document structure.
rq   r3   s    r   pathDocumentStructure.path   s     zzr   c                     Xl         g r    r{   )r   values     r   r|   r}      s    
r   c                 ,    [        U R                  5      $ r    )listrp   r3   s    r   available_sections$DocumentStructure.available_sections   s    DOO$$r   c                     U R                   $ r    )rr   r3   s    r   ru   DocumentStructure.context   s    }}r   c                 8    U H  nU R                  U5        M     g r    )add_new_section)r   rt   section_names      r   rs   %DocumentStructure._generate_structure   s    )L  . *r   c                    U R                  XR                  US9nU R                  U/-   Ul        U R                  R                  UR                  l        U R
                  Ul        U R                  Ul        X0R                  U'   U$ )a7  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   ru   )rv   r   r|   r   indentationr   r   rp   )r   r   ru   sections       r   r   !DocumentStructure.add_new_section   st      ..kk7 ! 
 yyD6)$(JJ$:$:!"&"6"6

 'r   c                      U R                   U   $ )zRetrieve a sectionrp   r   r   s     r   get_sectionDocumentStructure.get_section   s    t$$r   c                     U R                   U	 g)zDelete a sectionNr   r   s     r   delete_section DocumentStructure.delete_section   s    OOD!r   c                    [        U R                  5      nUS:X  aj  U R                  (       aX  U R                  R	                  5         U R                  R                  5        H   u  p4U R                  R                  X45        M"     O(U[        R                  U R                  S   5      :X  a  SnU R                  5       nU R                  R                  5        Hf  u  pg[        R                  UR                  5       5      nU(       a"  UR                  S5       S3R                  5       OUnXWR!                  U5      -  nMh     [        UR#                  5       5      n	[$        R                  U R&                  5      n
Ub  UR                  5       O[(        nU
(       a/  XS   :  a'  [*        R-                  U
S   U5      R                  5       nU$ )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   )r7   r|   r   r   rA   rB   rC   SECTION_METHOD_PATH_DEPTHrK   rH   rp   DOCUMENTATION_LINK_REGEXsearchdecodegrouprE   flush_structure
splitlinesSECTION_LINE_LIMIT_CONFIGr   DEFAULT_AWS_DOCS_LINKLARGE_SECTION_MESSAGEformat)r   	docs_linkpath_lengthrF   rG   r   r   r   match
line_countsection_configaws_docs_links               r   r   !DocumentStructure.flush_structure   sv    $))n!zz

((*%)ZZ%5%5%7MGJJ55gD &8 599$))A,GGI!__224MD -33ELLNCE495;;q>"$'..0y  ,,Y77E 5 ))+,
266tyyA $ & 	
 j,+GG)00v&fh  r   c                 V    SR                  U R                  5      R                  S5      $ )Nr?   r@   )rD   r   rE   r3   s    r   rH   DocumentStructure.getvalue  s     wwt||$++G44r   c                 "    [        5       U l        g r    )r   rp   r3   s    r   remove_all_sections%DocumentStructure.remove_all_sections
  s    %-r   c                     / U l         g r    r2   r3   s    r   
clear_textDocumentStructure.clear_text  s	    r   c                 ^    U R                  S5      nUR                  R                  U5        U$ )Ntitle)r   r   h1)r   r   title_sections      r   add_title_section#DocumentStructure.add_title_section  s,    ,,W5u%r   c                 F   [         R                  R                  U5      (       d  [         R                  " U5        [         R                  R	                  X S35      n[        US5       nUR                  U R                  5       5        S S S 5        g ! , (       d  f       g = f)Nz.rstwb)osr|   existsmakedirsrD   openr)   r   )r   	full_path	file_namesub_resource_file_pathfs        r   write_to_fileDocumentStructure.write_to_file  si    ww~~i((KK	"!#i;d9K!L($/1GGD((*+ 0//s   ) B
B )rr   ro   rq   rp   r   )Nrc   Nr    )rd   re   rf   rg   r   propertyr   r|   setterr   ru   rs   r   r   r   r   rH   r   r   r   r   rh   __classcell__)rv   s   @r   rk   rk      s    4.     
[[  % %  /6%"(T5(
, ,r   rk   )loggingr   rebotocore.compatr   #botocore.docs.bcdoc.docstringparserr   botocore.docs.bcdoc.styler   r   compiler   r   	getLoggerrY   r   r   r   rk   ri   r   r   <module>r      s     	 	 ' ? /@ ::I 	  !!2$G0E 0E+4@	   P( P(fU, U,r   