o
    Êó·i°  ã                   @   s>   d Z ddlZddg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.
é    NÚasReStructuredTextÚasStructuredTextFc                 C   s   |rdd„ }ndd„ }||   ¡ ƒg}|j}d}|  ¡ r&|tt|  ¡ ƒ|ƒƒ dd„ | jD ƒ}|rW|td||ƒƒ |d7 }|D ]}d||  ¡ ƒ }	|tt|	ƒ||ƒƒ q>|d8 }t|  ¡ ƒ}
|td	||ƒƒ |d7 }|
D ]!\}}t|d
ƒsŒd 	||  ¡ ƒ| ¡ p€d¡}	|tt|	ƒ||ƒƒ qk|d8 }|td||ƒƒ |d7 }|
D ])\}}t|d
ƒrÈ|  ¡ › | 
¡ › �}d 	||ƒ| ¡ p¼d¡}	|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| › d�S )Nz``© ©Úsr   r   ú]C:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\zope/interface/document.pyÚinline_literal%   s   z(asStructuredText.<locals>.inline_literalc                 S   s   | S )Nr   r   r   r   r   r   (   s   é   c                 S   s   g | ]
}|t jjur|‘qS r   )ÚzopeZ	interfaceZ	Interface)Ú.0Úbaser   r   r   Ú
<listcomp>2   s    

þz$asStructuredText.<locals>.<listcomp>zThis interface extends:zo %szAttributes:ÚgetSignatureStringz{} -- {}zno documentationzMethods:z

N)ÚgetNameÚappendZgetDocÚ_justify_and_indentÚ_trim_doc_stringÚ	__bases__ÚsortedÚnamesAndDescriptionsÚhasattrÚformatr   Újoin)ÚifaceÚmungeÚrstr   ÚrZoutpÚlevelÚbasesÚbÚitemr   ÚnameÚdescÚ_callr   r   r   r      sT   
ÿ


þ€

þ€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   N)r   )r   r   r   r   r   r   Y   s   c                 C   sZ   |   dd¡ d¡}| d¡g}|r(tdd„ |D ƒƒ}|D ]}| ||d… ¡ qd |¡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   g   s    ÿz$_trim_doc_string.<locals>.<listcomp>N)ÚreplaceÚsplitÚpopÚminr   r   )ÚtextÚlinesÚnlinesZ
min_indentr(   r   r   r   r   `   s   ÿ
r   éH   c                 C   s‚   d| }|r1g }|}|   ¡ } | D ]}d ||g¡}t|ƒ|kr&| |¡ |}q| |¡ d |¡S ||  ¡  dd¡ d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   o   s    
€

ÿr   )r   F)r   )r   r0   )Ú__doc__Zzope.interfacer
   Ú__all__r   r   r   r   r   r   r   r   Ú<module>   s   þ

=