
    Fe                        d Z ddlmZ ddlZddlZddlmZ  ej                  ej                  d         Z	d	dZ
d
ddZddZy)z#Utilities for docstring processing.    )annotationsN)Bodyfield_markerc                   d}i }g }| s| |fS t        |       D ]  }|j                         dk(  rd}|j                  |       *t        j	                  |      }|r|s|j                         dd j                  dd      d   }|j                  d      r8|dd j                         }||j                         d j                         ||<   |j                  |       d	}|j                  |        d
j                  |      |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)sin_other_elementmetadatalineslinematched
field_namenames           8/usr/lib/python3/dist-packages/sphinx/util/docstrings.pyseparate_metadatar      s   !HE({!!$ #::<2$LL(..t4G/$]]_QR066sA>qA
((1%ab>//1D%)'++-.%9%?%?%AHTNLL&#' T"#" 99UX%%    c                   | j                  |      j                         }t        j                  }|dd D ]8  }t	        |j                               }|st	        |      |z
  }t        ||      }: t	        |      r|d   j                         |d<   |t        j                  k  r%t        dt	        |            D ]  }||   |d ||<    |r|d   s|j                  d       |r|d   s|r|d   r|j                  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   tabsizer   marginr   contentindentis           r   r   r   *   s     LL!,,.E[[Fab	 )dkkm$Y(F(F	) 5z8??$aq#e*% 	)AQx(E!H	) a		! a rRLr    c                2   g }| j                         j                         D cg c]  }|j                          }}|D ]9  }|j                  d      s|dd }|r|d   dk(  r|dd }|j	                  |       ; |r|d   r|j	                  d       |S c c}w )	zExtract documentation comment lines (starting with #:) and return them
    as a list of lines.  Returns an empty list if there is no documentation.
    z#:   Nr    r   r"   r   )r#   r$   r   r   r   )r   resultr   r   s       r   prepare_commentdocr5   I   s     F&'lln&?&?&ABdTZZ\BEB  ??4 8DQ3ABxMM$  &*bM Cs   B)r   z
str | Nonereturnz!tuple[str | None, dict[str, str]])   )r   strr,   intr6   	list[str])r   r8   r6   r:   )__doc__
__future__r   rer%   docutils.parsers.rst.statesr   compilepatternsr   r   r   r5    r    r   <module>rB      s=    ) " 	 
 ,RZZn => &:>r    