B
    .ÛKc£  ã               @   sÀ   d Z ddlZddlZddlZddlmZmZmZ ddlm	Z	 ddl
mZ e e	jd ¡Zeeeeeef f dœdd	„Zeeeef dœd
d„Zdeeee dœdd„Zeee dœdd„ZdS )z#Utilities for docstring processing.é    N)ÚDictÚListÚTuple)ÚBody)ÚRemovedInSphinx60WarningZfield_marker)ÚsÚreturnc             C   sÐ   d}i }g }| s| |fS x¨t | ƒD ]œ}| ¡ dkrBd}| |¡ q"t |¡}|r°|s°| ¡ dd…  dd¡d }| d¡r¤|dd…  ¡ }|| ¡ d…  ¡ ||< q¾| |¡ q"d	}| |¡ q"W d
 	|¡|fS )z,Separate docstring into metadata and others.FÚ é   Nú:r   zmeta é   TÚ
)
Úprepare_docstringÚstripÚappendÚfield_list_item_reÚmatchÚgroupÚsplitÚ
startswithÚendÚjoin)r   Zin_other_elementÚmetadataÚlinesÚlineZmatchedZ
field_nameÚname© r   ú5lib/python3.7/site-packages/sphinx/util/docstrings.pyÚseparate_metadata   s&    

r   c             C   s    t jdtdd t| ƒ\}}|S )Nz!extract_metadata() is deprecated.é   )Ú
stacklevel)ÚwarningsÚwarnr   r   )r   Z	docstringr   r   r   r   Úextract_metadata,   s    
r#   é   )r   Útabsizer   c             C   sÔ   |   |¡ ¡ }tj}x:|dd… D ]*}t| ¡ ƒ}|r"t|ƒ| }t||ƒ}q"W t|ƒrh|d  ¡ |d< |tjk ržx*tdt|ƒƒD ]}|| |d… ||< q‚W x|r¸|d s¸| d¡ q W |rÐ|d rÐ| 	d¡ |S )aw  Convert a docstring into lines of parseable reST.  Remove common leading
    indentation, where the indentation of the first line is ignored.

    Return the docstring as a list of lines usable for inserting into a docutils
    ViewList (used as argument of nested_parse().)  An empty line is added to
    act as a separator between this docstring and following content.
    r
   Nr   éÿÿÿÿr	   )
Ú
expandtabsÚ
splitlinesÚsysÚmaxsizeÚlenÚlstripÚminÚrangeÚpopr   )r   r%   r   Zmarginr   ZcontentÚindentÚir   r   r   r   4   s"    

r   c             C   s~   g }dd„ |   ¡  ¡ D ƒ}xH|D ]@}| d¡r |dd… }|rV|d dkrV|dd… }| |¡ q W |rz|d	 rz| d
¡ |S )z˜Extract documentation comment lines (starting with #:) and return them
    as a list of lines.  Returns an empty list if there is no documentation.
    c             S   s   g | ]}|  ¡ ‘qS r   )r   )Ú.0r   r   r   r   ú
<listcomp>X   s    z&prepare_commentdoc.<locals>.<listcomp>z#:r   Nr   ú r
   r&   r	   )r'   r(   r   r   )r   Úresultr   r   r   r   r   Úprepare_commentdocS   s    


r6   )r$   )Ú__doc__Úrer)   r!   Útypingr   r   r   Zdocutils.parsers.rst.statesr   Zsphinx.deprecationr   ÚcompileZpatternsr   Ústrr   r#   Úintr   r6   r   r   r   r   Ú<module>   s    