ó
ÔËÞKc           @   s:   d  Z  d d l Z d d „ Z d „  Z d d d „ Z d S(   sÖ    Pretty-Print an Interface object as structured text (Yum)

This module provides a function, asStructuredText, for rendering an
interface as structured text.

$Id: document.py 110536 2010-04-06 02:59:44Z tseaver $
iÿÿÿÿNi    c         C   s2  |  j  ƒ  g } | j } d } |  j ƒ  rL | t t |  j ƒ  ƒ | ƒ ƒ n  g  |  j D] } | t j j k	 rV | ^ qV } | rê | t d | | ƒ ƒ | d 7} x: | D]2 } d | j  ƒ  } | t t | ƒ | | ƒ ƒ q§ W| d 8} n  |  j	 ƒ  }	 |	 j
 ƒ  | t d | | ƒ ƒ | d 7} xd |	 D]\ \ }
 } t | d ƒ s'd | j  ƒ  | j ƒ  p]d f } | t t | ƒ | | ƒ ƒ q'q'W| d 8} | t d | | ƒ ƒ | d 7} xm |	 D]e \ }
 } t | d ƒ r¸d	 | j  ƒ  | j ƒ  | j ƒ  p÷d f } | t t | ƒ | | ƒ ƒ q¸q¸Wd
 j | ƒ d
 S(   sj    Output structured text format.  Note, this will whack any existing
    'structured' format of the text.  i   s   This interface extends:s   o %ss   Attributes:t   getSignatureStrings   %s -- %ss   no documentations   Methods:s
   %s%s -- %ss   

(   t   getNamet   appendt   getDoct   _justify_and_indentt   _trim_doc_stringt	   __bases__t   zopet	   interfacet	   Interfacet   namesAndDescriptionst   sortt   hasattrR    t   join(   t   It   munget   rt   outpt   levelt   baset   basest   bt   itemR
   t   namet   desc(    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyt   asStructuredText   sD    	"
 

#

	#c         C   sš   |  j  d d ƒ j d ƒ } | j d ƒ g } | r t g  | D]" } t | ƒ t | j ƒ  ƒ ^ q= ƒ } x" | D] } | j | | ƒ qo Wn  d j | ƒ S(   sJ    Trims a doc string to make it format
    correctly with structured text. s   
s   
i    (   t   replacet   splitt   popt   mint   lent   lstripR   R   (   t   textt   linest   nlinest   linet
   min_indent(    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyR   F   s    /iH   c         C   s¾   d | } | r g  } | } |  j  ƒ  }  xX |  D]C } d j | | g ƒ } t | ƒ | k r/ | j | ƒ | } q/ q/ W| j | ƒ d j | ƒ S| |  j ƒ  j d d ƒ j d d | ƒ Sd S(   s9    indent and justify text, rejustify (munge) if specified t    s   
s   
N(   R   R   R   R   t   stripR   (   R    R   R   t   widtht   indentR!   R#   t   word(    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyR   U   s    
(   t   __doc__t   zope.interfaceR   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyt   <module>   s   /	