
    q&f                     >    d Z ddlmZ ddlmZ d
dZddZd ZddZy	)z Pretty-Print an Interface object as structured text (Yum)

This module provides a function, asStructuredText, for rendering an
interface as structured text.
    )absolute_import   )	Interfacec                 >   |rd }nd } || j                               g}|j                  }d}| j                         r) |t        t	        | j                               |             | j
                  D cg c]  }|t        ur| }}|rY |t        d||             |dz  }|D ]7  }	d ||	j                               z  }
 |t        t	        |
      ||             9 |dz  }t        | j                               } |t        d||             |dz  }|D ][  \  }}t        |d      r ||j                               d|j                         xs d	}
 |t        t	        |
      ||             ] |dz  } |t        d
||             |dz  }|D ]o  \  }}t        |d      s|j                         |j                         } ||      d|j                         xs d	}
 |t        t	        |
      ||             q dj                  |      dz   S c c}w )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                     d| dS )Nz`` ss    N/usr/lib/python3/dist-packages/mercurial/thirdparty/zope/interface/document.py<lambda>z"asStructuredText.<locals>.<lambda>!   s    q?     c                     | S )Nr   r	   s    r   r   z"asStructuredText.<locals>.<lambda>#   s    1 r   r   zThis interface extends:zo %szAttributes:getSignatureStringz -- zno documentationzMethods:z

)getNameappendgetDoc_justify_and_indent_trim_doc_string	__bases__r   sortednamesAndDescriptionshasattrr   join)Imungerstinline_literalroutplevelbasebasesbitemr   namedesc_calls                  r   asStructuredTextr(      s/    2$				$%A88DExxz !1!((*!=uEF I%  E   !:E5IJ
 	LAN199;77D$%5d%;UEJK	L 	
!!"8"8":;	]E5	9:	QJE* L
dt12!/!?!%!D2D!DFD$%5d%;UEJK	L
 
QJE	Z	67	QJE* L
d4-."llnd.E.E.GHE!/!6!%!D2D!DFD$%5d%;UEJKL ;;q>F""As   6Hc                     t        | |d      S )zi Output reStructuredText format.  Note, this will whack any existing
    'structured' format of the text.T)r   r   )r(   )r   r   s     r   asReStructuredTextr*   O   s     AU55r   c           
      F   | j                  dd      j                  d      }|j                  d      g}|rWt        |D cg c]'  }t	        |      t	        |j                               z
  ) c}      }|D ]  }|j                  ||d         dj                  |      S c c}w )zJ Trims a doc string to make it format
    correctly with structured text. 

r   N)replacesplitpopminlenlstripr   r   )textlinesnlinesline
min_indents        r   r   r   U   s     LL&,,T2Eiil^F&+-" d)c$++-&88 - .
 	-DMM$z{+,	- 99V-s   ,Bc                 `   d|z  }|rrg }|}| j                         } | D ]7  }dj                  ||g      }t        |      |kD  s%|j                  |       |}9 |j                  |       dj                  |      S || j	                         j                  dd      j                  dd|z         z   S )z9 indent and justify text, rejustify (munge) if specified  r-   r,   )r/   r   r2   r   stripr.   )r4   r    r   widthindentr5   r7   words           r   r   r   d   s     5[Fzz| 	D88T4L)D4y5 T"		 LLyy JJL  .77dVmLM 	Mr   N)r   F)r   )r   H   )	__doc__
__future__r    r   r(   r*   r   r   r   r   r   <module>rC      s(    ' 4#n6Mr   