ó
2(Vc           @   sI   d  Z  d d l Z d e d „ 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.
iÿÿÿÿNi    c         C   sn  | r d „  } n	 d „  } | |  j  ƒ  ƒ g } | j } d } |  j ƒ  rm | t t |  j ƒ  ƒ | ƒ ƒ n  g  |  j D] } | t j j k	 rw | ^ qw } | r| t d | | ƒ ƒ | d 7} x@ | D]8 }	 d | |	 j  ƒ  ƒ }
 | t t |
 ƒ | | ƒ ƒ qÈ W| d 8} n  t	 |  j
 ƒ  ƒ } | t d | | ƒ ƒ | d 7} xj | D]b \ } } t | d ƒ sJd | | j  ƒ  ƒ | j ƒ  p†d	 f }
 | t t |
 ƒ | | ƒ ƒ qJqJW| d 8} | t d
 | | ƒ ƒ | d 7} x€ | D]x \ } } t | d ƒ rád | j  ƒ  | j ƒ  f } d | | ƒ | j ƒ  p3d	 f }
 | t t |
 ƒ | | ƒ ƒ qáqáWd j | ƒ d S(   sõ    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(   Ns   ``%s``(    (   t   s(    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyt   <lambda>   s    c         S   s   |  S(   N(    (   R    (    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyR   !   s    i   s   This interface extends:s   o %ss   Attributes:t   getSignatureStrings   %s -- %ss   no documentations   Methods:s   %s%ss   

(   t   getNamet   appendt   getDoct   _justify_and_indentt   _trim_doc_stringt	   __bases__t   zopet	   interfacet	   Interfacet   sortedt   namesAndDescriptionst   hasattrR   t   join(   t   It   munget   rstt   inline_literalt   rt   outpt   levelt   baset   basest   bt   itemR   t   namet   desct   _call(    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyt   asStructuredText   sH    		"
 
#

#c         C   s   t  |  d | d t ƒS(   si    Output reStructuredText format.  Note, this will whack any existing
    'structured' format of the text.R   R   (   R   t   True(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyt   asReStructuredTextM   s    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   S   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   b   s    
(   t   __doc__t   zope.interfaceR	   t   FalseR   R    R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/zope/interface/document.pyt   <module>   s
   7	