3 [@s6dZddlZd ddZdddZdd Zdd d ZdS)z Pretty-Print an Interface object as structured text (Yum) This module provides a function, asStructuredText, for rendering an interface as structured text. NFcCs|rdd}ndd}||jg}|j}d}|jrL|tt|j|dd|jD}|r|td|||d7}x0|D](}d||j} |tt| ||q~W|d8}t|j} |td |||d7}xL| D]D\} } t| d sd || j| jpd f} |tt| ||qW|d8}|td |||d7}x`| D]X\} } t| d rJd| j| j f} d || | jpd f} |tt| ||qJWdj |dS)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. cSs d|fS)Nz``%s``)srr /usr/lib64/python3.6/document.pysz"asStructuredText..cSs|S)Nr)rrrrr!scSsg|]}|tjjk r|qSr)zopeZ interfaceZ Interface).0baserrr *sz$asStructuredText..zThis interface extends:zo %sz Attributes:getSignatureStringz%s -- %szno documentationzMethods:z%s%sz ) ZgetNameappendZgetDoc_justify_and_indent_trim_doc_string __bases__sortednamesAndDescriptionshasattrr join)ImungerstZinline_literalrZoutplevelbasesbitemrnameZdescZ_callrrrasStructuredTextsF       rcCst||ddS)zi Output reStructuredText format. Note, this will whack any existing 'structured' format of the text.T)rr)r)rrrrrasReStructuredTextMsrcCs^|jddjd}|jdg}|rTtdd|D}x|D]}|j||dq:Wdj|S)zJ Trims a doc string to make it format correctly with structured text. z  rcSs g|]}t|t|jqSr)lenlstrip)rlinerrrr Zsz$_trim_doc_string..N)replacesplitpopminr r)textlinesZnlinesZ min_indentr"rrrrSs   rHcCsd|}|rfg}|}|j}x>|D],}dj||g}t||kr"|j||}q"W|j|dj|S||jjddjdd|SdS)z9 indent and justify text, rejustify (munge) if specified  rz N)r$rr r stripr#)r'rrwidthindentr(r"Zwordrrrr bs     r )rF)r)rr))__doc__Zzope.interfacerrrrr rrrrs  7