B
    0`                 @   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}|  rL|tt|  | dd | jD }|r|td|| |d7 }x0|D ](}d||   }	|tt|	|| q~W |d8 }t|  }
|td	|| |d7 }xL|
D ]D\}}t|d
sd||  | pdf }	|tt|	|| qW |d8 }|td|| |d7 }x`|
D ]X\}}t|d
rJd|  |	 f }d||| pdf }	|tt|	|| qJW 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   F/home/dcms/DCMS/lib/python3.7/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   r      sF    



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   r   Q   s    c             C   s^   |  ddd}|dg}|rTtdd |D }x|D ]}|||d  q:W d|S )zJ Trims a doc string to make it format
    correctly with structured text. z

r   c             S   s    g | ]}t |t |  qS r   )lenlstrip)r   liner   r   r   r   ^   s   z$_trim_doc_string.<locals>.<listcomp>N)replacesplitpopminr   r   )textlinesnlinesZ
min_indentr%   r   r   r   r   W   s    

r   H   c             C   s   d| }|rfg }|}|   } x>| D ],}d||g}t||kr"|| |}q"W || d|S ||  dddd|  S dS )z9 indent and justify text, rejustify (munge) if specified  r"   z
N)r'   r   r#   r   stripr&   )r*   r   r   widthindentr+   r%   wordr   r   r   r   f   s    



r   )r   F)r   )r   r-   )__doc__Zzope.interfacer
   __all__r   r   r   r   r   r   r   r   <module>   s   
7
