U
    ÈZj”  ã                   @   s6   d Z ddlZddd„Zddd„Zdd	„ Zddd„ZdS )zž Pretty-Print an Interface object as structured text (Yum)

This module provides a function, asStructuredText, for rendering an
interface as structured text.
é    NFc                 C   s¨  |rdd„ }ndd„ }||   ¡ ƒg}|j}d}|  ¡ rL|tt|  ¡ ƒ|ƒƒ dd„ | jD ƒ}|r®|td||ƒƒ |d7 }|D ](}d||  ¡ ƒ }	|tt|	ƒ||ƒƒ q||d8 }t|  ¡ ƒ}
|td	||ƒƒ |d7 }|
D ]D\}}t|d
ƒsÖd||  ¡ ƒ| ¡ �p df }	|tt|	ƒ||ƒƒ qÖ|d8 }|td||ƒƒ |d7 }|
D ]X\}}t|d
ƒ�r@d|  ¡ | 	¡ f }d||ƒ| ¡ �p|df }	|tt|	ƒ||ƒƒ �q@d 
|¡d S )zõ Output structured text format.  Note, this will whack any existing
    'structured' format of the text.

    If `rst=True`, then the output will quote all code as inline literals in
    accordance with 'reStructuredText' markup principles.
    c                 S   s
   d| f S )Nz``%s``© ©Úsr   r   úZ/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/zope/interface/document.pyÚ<lambda>   ó    z"asStructuredText.<locals>.<lambda>c                 S   s   | S )Nr   r   r   r   r   r   !   r   é   c                 S   s   g | ]}|t jjk	r|‘qS r   )ÚzopeZ	interfaceZ	Interface)Ú.0Úbaser   r   r   Ú
<listcomp>*   s   þz$asStructuredText.<locals>.<listcomp>zThis interface extends:zo %szAttributes:ÚgetSignatureStringz%s -- %szno documentationzMethods:z%s%sz

)ÚgetNameÚappendZgetDocÚ_justify_and_indentÚ_trim_doc_stringÚ	__bases__ÚsortedÚnamesAndDescriptionsÚhasattrr   Újoin)ÚIÚmungeÚrstZinline_literalÚrZoutpÚlevelÚbasesÚbÚitemr   ÚnameÚdescZ_callr   r   r   ÚasStructuredText   sL    
ÿ
ÿÿr!   c                 C   s   t | |dd�S )zi Output reStructuredText format.  Note, this will whack any existing
    'structured' format of the text.T)r   r   )r!   )r   r   r   r   r   ÚasReStructuredTextM   s    r"   c                 C   sZ   |   dd¡ d¡}| d¡g}|rPtdd„ |D ƒƒ}|D ]}| ||d… ¡ q8d |¡S )zJ Trims a doc string to make it format
    correctly with structured text. ú
Ú
r   c                 S   s    g | ]}t |ƒt | ¡ ƒ ‘qS r   )ÚlenÚlstrip)r
   Úliner   r   r   r   Z   s   ÿz$_trim_doc_string.<locals>.<listcomp>N)ÚreplaceÚsplitÚpopÚminr   r   )ÚtextÚlinesÚnlinesZ
min_indentr'   r   r   r   r   S   s    ÿr   éH   c                 C   s†   d| }|rbg }|}|   ¡ } | D ],}d ||g¡}t|ƒ|kr | |¡ |}q | |¡ d |¡S ||  ¡  dd¡ dd| ¡ S dS )z9 indent and justify text, rejustify (munge) if specified ú r$   r#   N)r)   r   r%   r   Ústripr(   )r,   r   r   ÚwidthÚindentr-   r'   Úwordr   r   r   r   b   s    


ÿr   )r   F)r   )r   r/   )Ú__doc__Zzope.interfacer	   r!   r"   r   r   r   r   r   r   Ú<module>   s
   
7
