U
    mª/e\3  ã                   @   s8   d dl Z e  d¡ZdZG dd„ dƒZG dd„ deƒZdS )é    NZbcdocs)Ú.ú,ú?ú!ú:ú;c                   @   sŠ   e Zd Zddd„Zedd„ ƒZejdd„ ƒZdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zddd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS ) Ú	BaseStyleé   c                 C   s   || _ || _d| _d| _d S )Nr   T)ÚdocÚindent_widthÚ_indentÚ	keep_data©Úselfr
   r   © r   ú=/tmp/pip-unpacked-wheel-3gylhwtm/botocore/docs/bcdoc/style.pyÚ__init__   s    zBaseStyle.__init__c                 C   s   | j S ©N©r   ©r   r   r   r   Úindentation   s    zBaseStyle.indentationc                 C   s
   || _ d S r   r   )r   Úvaluer   r   r   r       s    c                 C   s   d|   ¡  S ©Nz
%s)Úspacesr   r   r   r   Únew_paragraph$   s    zBaseStyle.new_paragraphc                 C   s   |  j d7  _ d S )Né   r   r   r   r   r   Úindent'   s    zBaseStyle.indentc                 C   s   | j dkr|  j d8  _ d S ©Nr   r   r   r   r   r   r   Údedent*   s    
zBaseStyle.dedentc                 C   s   d| j | j  S )Nú )r   r   r   r   r   r   r   .   s    zBaseStyle.spacesc                 C   s   |S r   r   ©r   Úsr   r   r   Úbold1   s    zBaseStyle.boldNc                 C   s   |S r   r   )r   ÚlinkÚtitler   r   r   Úref4   s    zBaseStyle.refc                 C   s   |S r   r   r    r   r   r   Úh27   s    zBaseStyle.h2c                 C   s   |S r   r   r    r   r   r   Úh3:   s    zBaseStyle.h3c                 C   s   |S r   r   r    r   r   r   Ú	underline=   s    zBaseStyle.underlinec                 C   s   |S r   r   r    r   r   r   Úitalics@   s    zBaseStyle.italicsc                 C   sB   | j  ¡ }|d krd}|dkr2|d dkr2|d7 }| j  |¡ d S )NÚ éÿÿÿÿr   )r
   Ú	pop_writeÚ
push_write)r   Ú
last_writer   r   r   Ú$add_trailing_space_to_previous_writeC   s    
z.BaseStyle.add_trailing_space_to_previous_write)r	   )N)Ú__name__Ú
__module__Ú__qualname__r   Úpropertyr   Úsetterr   r   r   r   r"   r%   r&   r'   r(   r)   r/   r   r   r   r   r      s    



r   c                   @   s:  e Zd Zdƒdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zd„dd„Zdd„ Z	d…dd„Z
dd„ Zdd„ Zd†dd„Zdd„ Zdd„ Zdd„ Zdd „ Zd‡d!d"„Zd#d$„ Zd%d&„ Zdˆd'd(„Zd)d*„ Zd‰d+d,„Zd-d.„ Zd/d0„ ZdŠd1d2„Zd3d4„ Zd‹d5d6„Zd7d8„ ZdŒd9d:„Zd;d<„ Zdd=d>„Z d?d@„ Z!dŽdAdB„Z"dCdD„ Z#ddEdF„Z$ddGdH„Z%dIdJ„ Z&d‘dKdL„Z'dMdN„ Z(dOdP„ Z)d’dQdR„Z*dSdT„ Z+d“dUdV„Z,dWdX„ Z-d”dYdZ„Z.d[d\„ Z/d•d]d^„Z0d_d`„ Z1d–dadb„Z2dcdd„ Z3dedf„ Z4dgdh„ Z5d—didj„Z6dkdl„ Z7dmdn„ Z8d˜dodp„Z9dqdr„ Z:dsdt„ Z;d™dudv„Z<dwdx„ Z=dydz„ Z>d{d|„ Z?d}d~„ Z@dd€„ ZAdd‚„ ZBdS )šÚ	ReSTStyler	   c                 C   s$   t  | ||¡ d| _d | _d| _d S )NTr   )r   r   Údo_pÚa_hrefÚ
list_depthr   r   r   r   r   O   s    zReSTStyle.__init__c                 C   s   | j  d|  ¡  ¡ d S ©Nz

%s©r
   Úwriter   r   r   r   r   r   U   s    zReSTStyle.new_paragraphc                 C   s   | j  d|  ¡  ¡ d S r   r:   r   r   r   r   Únew_lineX   s    zReSTStyle.new_linec                 C   sP   z| j  ¡ }W n tk
r"   Y nX |dkr@|dkr@| j  d¡ | j  |¡ d S )N)Ú*ú**r   )r
   Z
peek_writeÚ
IndexErrorr;   ©r   Zmarkupr.   r   r   r   Ú_start_inline[   s    zReSTStyle._start_inlinec                 C   s2   | j  ¡ }||krd S | j  |¡ | j  |¡ d S r   )r
   r,   r-   r;   r@   r   r   r   Ú_end_inlineg   s
    
zReSTStyle._end_inlineNc                 C   s   |   d¡ d S ©Nr>   ©rA   ©r   Úattrsr   r   r   Ú
start_boldr   s    zReSTStyle.start_boldc                 C   s   |   d¡ d S rC   ©rB   r   r   r   r   Úend_boldu   s    zReSTStyle.end_boldc                 C   s   d| j _|  |¡ d S ©NT)r
   Údo_translationrG   rE   r   r   r   Ústart_bx   s    zReSTStyle.start_bc                 C   s   d| j _|  ¡  d S ©NF)r
   rK   rI   r   r   r   r   Úend_b|   s    zReSTStyle.end_bc                 C   s$   |r |   ¡  | j |¡ |  ¡  d S r   )rG   r
   r;   rI   r    r   r   r   r"   €   s    zReSTStyle.boldc                 C   s*   |d kr|}| j  d|› d|› d¡ d S )Nú:doc:`ú <ú>`)r
   r;   ©r   r$   r#   r   r   r   r%   †   s    zReSTStyle.refc                 C   s<   |t |ƒ }|  ¡  | j |› d|› d|› ¡ |  ¡  d S )NÚ
)Úlenr   r
   r;   )r   r!   Zborder_charZborderr   r   r   Ú_heading‹   s    zReSTStyle._headingc                 C   s   |   |d¡ d S ©Nr=   ©rU   r    r   r   r   Úh1‘   s    zReSTStyle.h1c                 C   s   |   |d¡ d S )Nú=rW   r    r   r   r   r&   ”   s    zReSTStyle.h2c                 C   s   |   |d¡ d S )Nú-rW   r    r   r   r   r'   —   s    zReSTStyle.h3c                 C   s   |   d¡ d S rV   rD   rE   r   r   r   Ústart_italicsš   s    zReSTStyle.start_italicsc                 C   s   |   d¡ d S rV   rH   r   r   r   r   Úend_italics   s    zReSTStyle.end_italicsc                 C   s$   |r |   ¡  | j |¡ |  ¡  d S r   )r[   r
   r;   r\   r    r   r   r   r)       s    zReSTStyle.italicsc                 C   s   | j r| j d|  ¡  ¡ d S r9   ©r6   r
   r;   r   rE   r   r   r   Ústart_p¦   s    zReSTStyle.start_pc                 C   s   | j r| j d|  ¡  ¡ d S r9   r]   r   r   r   r   Úend_pª   s    zReSTStyle.end_pc                 C   s   d| j _|  ¡  |  d¡ d S )NTú``)r
   rK   r/   rA   rE   r   r   r   Ú
start_code®   s    zReSTStyle.start_codec                 C   s   d| j _|  d¡ d S )NFr`   )r
   rK   rB   r   r   r   r   Úend_code³   s    zReSTStyle.end_codec                 C   s$   |r |   ¡  | j |¡ |  ¡  d S r   )ra   r
   r;   rb   r    r   r   r   Úcode·   s    zReSTStyle.codec                 C   s(   |   ¡  | j d¡ |  ¡  |   ¡  d S )Nz	.. note::©r   r
   r;   r   rE   r   r   r   Ú
start_note½   s    zReSTStyle.start_notec                 C   s   |   ¡  |  ¡  d S r   ©r   r   r   r   r   r   Úend_noteÃ   s    zReSTStyle.end_notec                 C   s(   |   ¡  | j d¡ |  ¡  |   ¡  d S )Nz.. warning::rd   rE   r   r   r   Ústart_importantÇ   s    zReSTStyle.start_importantc                 C   s   |   ¡  |  ¡  d S r   rf   r   r   r   r   Úend_importantÍ   s    zReSTStyle.end_importantc                 C   s(   |   ¡  | j d¡ |  ¡  |   ¡  d S )Nz.. danger::rd   rE   r   r   r   Ústart_dangerÑ   s    zReSTStyle.start_dangerc                 C   s   |   ¡  |  ¡  d S r   rf   r   r   r   r   Ú
end_danger×   s    zReSTStyle.end_dangerc                 C   sR   |   ¡  |r:|D ]&\}}|dkr| ¡ | _| j d¡ qn| j d¡ d| j_d S )NÚhrefú`r   T)r/   Ústripr7   r
   r;   rK   )r   rF   Zattr_keyÚ
attr_valuer   r   r   Ústart_aÛ   s    
zReSTStyle.start_ac                 C   s   | j  d|› d|› ¡ d S )Nz.. _z: )r
   Úwriteln)r   Zrefnamer#   r   r   r   Úlink_target_definitionî   s    z ReSTStyle.link_target_definitionc                 C   sD   |d kr|}| j jdkr4| j  d|› d|› d¡ n| j  |¡ d S )NÚhtmlz:ref:`rP   rQ   ©r
   Útargetr;   )r   ÚlabelÚtextr   r   r   Úsphinx_reference_labelñ   s
    z ReSTStyle.sphinx_reference_labelc                 C   s^   | j }| ¡ }| d¡s&| ¡ | }q|dkrZ| d¡rPd|dd …  d¡› }| |¡ d S )Nrm   r*   z` r   r   )r
   r,   Ú
startswithÚlstripr-   )r   r
   r.   r   r   r   Ú_clean_link_textù   s    

zReSTStyle._clean_link_textc                 C   sº   d| j _| jr¶|  ¡  | j  ¡ }| d¡}|rj|dkrjd|krJ| dd¡}| j  |¡ | j  d| j ¡ nF|dkr†| j  d| j ¡ n*| j  | j¡ | j| j j| j< | j  	d¡ d | _d S )	NFr   rm   r   z\:z <%s>`__z`<%s>`__z`__)
r
   rK   r7   r{   r,   ÚrstripÚreplacer-   Zhrefsr;   )r   Z
next_childr.   r   r   r   Úend_a  s     

zReSTStyle.end_ac                 C   s   d| j _|  ¡  d S rJ   )r
   rK   r[   rE   r   r   r   Ústart_i  s    zReSTStyle.start_ic                 C   s   d| j _|  ¡  d S rM   )r
   rK   r\   r   r   r   r   Úend_i!  s    zReSTStyle.end_ic                 C   s   |   ¡  d| _| j d¡ d S )NFz* )r<   r6   r
   r;   rE   r   r   r   Ústart_li%  s    zReSTStyle.start_lic                 C   s   d| _ |  ¡  d S rJ   )r6   r<   r   r   r   r   Úend_li*  s    zReSTStyle.end_lic                 C   s$   |r |   ¡  | j |¡ |  ¡  d S r   )r   r
   rq   r‚   r    r   r   r   Úli.  s    zReSTStyle.lic                 C   s,   | j dkr|  ¡  |  j d7  _ |  ¡  d S r   ©r8   r   r   rE   r   r   r   Ústart_ul4  s    
zReSTStyle.start_ulc                 C   s,   |  j d8  _ | j dkr |  ¡  |  ¡  d S ©Nr   r   ©r8   r   r   r   r   r   r   Úend_ul:  s    
zReSTStyle.end_ulc                 C   s,   | j dkr|  ¡  |  j d7  _ |  ¡  d S r   r„   rE   r   r   r   Ústart_ol@  s    
zReSTStyle.start_olc                 C   s,   |  j d8  _ | j dkr |  ¡  |  ¡  d S r†   r‡   r   r   r   r   Úend_olG  s    
zReSTStyle.end_olc                 C   s   d| j _d S rM   ©r
   r   rE   r   r   r   Ústart_examplesM  s    zReSTStyle.start_examplesc                 C   s   d| j _d S rJ   r‹   r   r   r   r   Úend_examplesP  s    zReSTStyle.end_examplesc                 C   s   d| j _d S rM   r‹   rE   r   r   r   Ústart_fullnameS  s    zReSTStyle.start_fullnamec                 C   s   d| j _d S rJ   r‹   r   r   r   r   Úend_fullnameV  s    zReSTStyle.end_fullnamec                 C   s    | j  d¡ |  ¡  |  ¡  d S )Nz::)r
   r;   r   r   rE   r   r   r   Ústart_codeblockY  s    zReSTStyle.start_codeblockc                 C   s   |   ¡  |  ¡  d S r   rf   r   r   r   r   Úend_codeblock^  s    zReSTStyle.end_codeblockc                 C   s    |   ¡  | j |¡ |  ¡  dS )zò
        Literal code blocks are introduced by ending a paragraph with
        the special marker ::.  The literal block must be indented
        (and, like all paragraphs, separated from the surrounding
        ones by blank lines).
        N)r   r
   rq   r‘   )r   rc   r   r   r   Ú	codeblockb  s    zReSTStyle.codeblockc                 C   s>   | j jdkr2| j  d¡ | j  d¡ | j  d¡ n|  ¡  d S )Nrs   ú
.. toctree::
ú  :maxdepth: 1
z  :titlesonly:

)r
   ru   r;   r…   r   r   r   r   Útoctreem  s
    zReSTStyle.toctreec                 C   sB   | j jdkr|  |¡ n&|r.| j  d| ¡ n| j  d| ¡ d S )NZmanz  %s)r
   ru   rƒ   rq   )r   ÚitemÚ	file_namer   r   r   Útocitemu  s
    zReSTStyle.tocitemc                 C   s4   | j jdkr0| j  d¡ | j  d¡ | j  d¡ d S )Nrs   r“   r”   z  :hidden:

rt   r   r   r   r   Úhidden_toctree~  s    zReSTStyle.hidden_toctreec                 C   s   | j jdkr|  |¡ d S )Nrs   )r
   ru   r˜   )r   r–   r   r   r   Úhidden_tocitem„  s    zReSTStyle.hidden_tocitemc                 C   s<   | j  d¡ |d k	r | j  |¡ |d k	r8| j  d| ¡ d S )Nz.. contents:: z   :depth: %s)r
   r;   rq   )r   r$   Údepthr   r   r   Útable_of_contentsˆ  s
    zReSTStyle.table_of_contentsc                 C   s,   |   ¡  | j d| ¡ |  ¡  |   ¡  d S )Nz.. py:class:: %srd   )r   Ú
class_namer   r   r   Ústart_sphinx_py_class  s    zReSTStyle.start_sphinx_py_classc                 C   s   |   ¡  |  ¡  d S r   rf   r   r   r   r   Úend_sphinx_py_class•  s    zReSTStyle.end_sphinx_py_classc                 C   sD   |   ¡  d| }|d k	r$|d| 7 }| j |¡ |  ¡  |   ¡  d S )Nz.. py:method:: %sz(%s)rd   )r   Úmethod_nameÚ
parametersÚcontentr   r   r   Ústart_sphinx_py_method™  s    z ReSTStyle.start_sphinx_py_methodc                 C   s   |   ¡  |  ¡  d S r   rf   r   r   r   r   Úend_sphinx_py_method¢  s    zReSTStyle.end_sphinx_py_methodc                 C   s,   |   ¡  | j d| ¡ |  ¡  |   ¡  d S )Nz.. py:attribute:: %srd   )r   Ú	attr_namer   r   r   Ústart_sphinx_py_attr¦  s    zReSTStyle.start_sphinx_py_attrc                 C   s   |   ¡  |  ¡  d S r   rf   r   r   r   r   Úend_sphinx_py_attr¬  s    zReSTStyle.end_sphinx_py_attrc                 C   s"   |  ¡ }|D ]}| j |¡ qd S r   )Ú
splitlinesr
   rq   )r   Z	docstringZdocstring_linesZdocstring_liner   r   r   Úwrite_py_doc_string°  s    zReSTStyle.write_py_doc_stringc                 C   s8   | j jdkr(| j  d|› d|› d¡ n| j  |¡ d S )Nrs   rm   rP   z>`_rt   rR   r   r   r   Úexternal_linkµ  s    zReSTStyle.external_linkc                 C   s8   | j jdkr(| j  d|› d|› d¡ n| j  |¡ d S )Nrs   rO   rP   rQ   rt   )r   r$   Úpager   r   r   Úinternal_link»  s    zReSTStyle.internal_link)r	   )N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NN)N)Cr0   r1   r2   r   r   r<   rA   rB   rG   rI   rL   rN   r"   r%   rU   rX   r&   r'   r[   r\   r)   r^   r_   ra   rb   rc   re   rg   rh   ri   rj   rk   rp   rr   rx   r{   r~   r   r€   r   r‚   rƒ   r…   rˆ   r‰   rŠ   rŒ   r   rŽ   r   r   r‘   r’   r•   r˜   r™   rš   rœ   rž   rŸ   r£   r¤   r¦   r§   r©   rª   r¬   r   r   r   r   r5   N   s€   




















	

	r5   )ÚloggingÚ	getLoggerÚloggerZPUNCTUATION_CHARACTERSr   r5   r   r   r   r   Ú<module>   s   
9