o
    EôjëD  ã                	   @   sâ  d Z ddlZddlZddlZddlZddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZ d^dejdejfdd	„Zd
edeje fdd„Zejdejd�Ze d¡Ze d¡Ze d¡Ze d¡Ze d¡ZG dd„ dƒZG dd„ deƒZ G dd„ deƒZ!G dd„ de ƒZ"G dd„ de ƒZ#G dd„ de ƒZ$G d d!„ d!e$ƒZ%G d"d#„ d#e!ƒZ&G d$d%„ d%eƒZ'g e"d&d'ƒ‘e"d(d'ƒ‘e"d)d'ƒ‘e"d*d'ƒ‘e"d+d,ƒ‘e"d-d,ƒ‘e"d.d,ƒ‘e"d/d,ƒ‘e"d0d1ƒ‘e"d2d1ƒ‘e#d3d4ƒ‘e#d5d4ƒ‘e#d6d7ƒ‘e#d8d7ƒ‘e"d9d:ƒ‘e"d;d:ƒ‘e$d<d=ƒ‘e$d>d=ƒ‘e%d?d@ƒ‘e%dAd@ƒ‘e'dBdCƒ‘e'dDdCƒ‘edEdFƒ‘edGdFƒ‘edHdIƒ‘edJdIƒ‘edKdLƒ‘edMdLƒ‘edNdOƒ‘edPdOƒ‘e&dQdRƒ‘Z(G dSdT„ dTƒZ)dUeje de	fdVdW„Z*ej+dXfdYe	dZed[edefd\d]„Z,dS )_z_Numpydoc-style docstring parsing.

:see: https://numpydoc.readthedocs.io/en/latest/format.html
é    N)Údedenté   )	Ú	DocstringÚDocstringDeprecatedÚDocstringExampleÚDocstringMetaÚDocstringParamÚDocstringRaisesÚDocstringReturnsÚDocstringStyleÚRenderingStyleÚiterableÚreturnc                 C   s(   t  | ¡\}}t|d ƒ t j|||d�S )N)Ú	fillvalue)Ú	itertoolsÚteeÚnextÚzip_longest)r   ÚendÚleftÚright© r   új/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/docstring_parser/numpydoc.pyÚ	_pairwise   s   
r   Ústringc                 C   s   |   ¡ } t| ƒdkr| S d S )Nr   )ÚstripÚlen)r   r   r   r   Ú
_clean_str   s   r   z	^[^\s].*$©Úflagsz(^(?P<name>.*?)(?:\s*:\s*(?P<type>.*?))?$z)(?P<type>.*?)(?:, optional|\(optional\))$zI(?P<type>.*?)(?:, default|\(default\))(?: | |=| = |= |: |)*(?P<value>.*)$z`(?<!\S)[Dd]efault(?:s to |(?:\s*(?:is|[=:])\s*|\s+))(?P<value>(?:['\"]).*?(?:['\"])|[\w\-\.]*\w)z(^(?:(?P<name>.*?)\s*:\s*)?(?P<type>.*?)$c                   @   sP   e Zd ZdZdededdfdd„Zedefdd	„ƒZd
edej	e
 fdd„ZdS )ÚSectiona‡  Numpydoc section parser.

    :param title: section title. For most sections, this is a heading like
                  "Parameters" which appears on its own line, underlined by
                  en-dashes ('-') on the following line.
    :param key: meta key string. In the parsed ``DocstringMeta`` instance this
                will be the first element of the ``args`` attribute list.
    ÚtitleÚkeyr   Nc                 C   s   || _ || _d S ©N)r!   r"   )Úselfr!   r"   r   r   r   Ú__init__I   s   
zSection.__init__c                 C   s"   dt | jƒ }d| j› d|› d�S )z§Regular expression pattern matching this section's header.

        This pattern will match this instance's ``title`` attribute in
        an anonymous group.
        ú-z^(z)\s*?\nz\s*$)r   r!   )r$   Zdashesr   r   r   Útitle_patternM   s   zSection.title_patternÚtextc                 c   s   � t | jgt|ƒd�V  dS )zÁParse ``DocstringMeta`` objects from the body of this section.

        :param text: section body text. Should be cleaned with
                     ``inspect.cleandoc`` before parsing.
        )ÚdescriptionN)r   r"   r   )r$   r(   r   r   r   ÚparseW   s   €zSection.parse)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr%   Úpropertyr'   ÚTÚIterabler   r*   r   r   r   r   r    ?   s    		r    c                   @   s>   e Zd ZdZdededefdd„Zdedeje fdd	„Z	d
S )Ú
_KVSectionzÚBase parser for numpydoc sections with key-value syntax.

    E.g. sections that look like this:
        key
            value
        key2 : type
            values can also span...
            ... multiple lines
    r"   Úvaluer   c                 C   s   d S r#   r   ©r$   r"   r4   r   r   r   Ú_parse_itemk   s   z_KVSection._parse_itemr(   c                 c   s`   � t t |¡ƒD ]%\}}| ¡ }|d ur| ¡ nd }|||… }| j| ¡ t |¡d�V  qd S )N)r"   r4   )	r   ÚKV_REGEXÚfinditerr   Ústartr6   ÚgroupÚinspectÚcleandoc)r$   r(   ÚmatchZ
next_matchr9   r   r4   r   r   r   r*   n   s   €
ÿüz_KVSection.parseN)
r+   r,   r-   r.   r/   r   r6   r1   r2   r*   r   r   r   r   r3   `   s    
r3   c                   @   s"   e Zd ZdZedefdd„ƒZdS )Ú_SphinxSectionz®Base parser for numpydoc sections with sphinx-style syntax.

    E.g. sections that look like this:
        .. title:: something
            possibly over multiple lines
    r   c                 C   s   d| j › d�S )Nz	^\.\.\s*(z)\s*::©r!   ©r$   r   r   r   r'   €   s   z_SphinxSection.title_patternN)r+   r,   r-   r.   r0   r/   r'   r   r   r   r   r>   x   s    r>   c                   @   ó&   e Zd ZdZdededefdd„ZdS )ÚParamSectionzíParser for numpydoc parameter sections.

    E.g. any section that looks like this:
        arg_name
            arg_description
        arg_2 : type, optional
            descriptions can also span...
            ... multiple lines
    r"   r4   r   c           
      C   sÜ   t  |¡}d  } } }}|d urG| d¡}| d¡}|d urGt |¡}|d ur0| d¡}d}nd}t |¡}	|	d urGd}|	 d¡}|	 d¡}t|ƒdkr_|d u r_t |¡}	|	d ur_|	 d¡}t| j	|gt
|ƒ||||d�S )NÚnameÚtypeTFr4   r   )Úargsr)   Úarg_nameÚ	type_nameÚis_optionalÚdefault)ÚPARAM_KEY_REGEXr=   r:   ÚPARAM_OPTIONAL_REGEXÚPARAM_DEFAULT_REGEXr   ÚPARAM_DEFAULT_REGEX_IN_DESCÚsearchr   r"   r   )
r$   r"   r4   r=   rF   rG   rH   rI   Zoptional_matchZdefault_matchr   r   r   r6   �   s8   









úzParamSection._parse_itemN)r+   r,   r-   r.   r/   r   r6   r   r   r   r   rB   …   s    
rB   c                   @   rA   )ÚRaisesSectionz¡Parser for numpydoc raises sections.

    E.g. any section that looks like this:
        ValueError
            A description of what might raise ValueError
    r"   r4   r   c                 C   s,   t | j|gt|ƒt|ƒdkr|d�S d d�S )Nr   )rE   r)   rG   )r	   r"   r   r   r5   r   r   r   r6   ½   s   ýýzRaisesSection._parse_itemN)r+   r,   r-   r.   r/   r	   r6   r   r   r   r   rO   µ   s    rO   c                   @   s*   e Zd ZdZdZdededefdd„ZdS )	ÚReturnsSectionzñParser for numpydoc returns sections.

    E.g. any section that looks like this:
        return_name : type
            A description of this returned value
        another_type
            Return names are optional, types are required
    Fr"   r4   r   c                 C   sL   t  |¡}|d ur| d¡}| d¡}nd }d }t| jgt|ƒ|| j|d�S )NrC   rD   )rE   r)   rG   Úis_generatorÚreturn_name)ÚRETURN_KEY_REGEXr=   r:   r
   r"   r   rQ   )r$   r"   r4   r=   rR   rG   r   r   r   r6   Ñ   s   

ûzReturnsSection._parse_itemN)r+   r,   r-   r.   rQ   r/   r
   r6   r   r   r   r   rP   Å   s    	rP   c                   @   s   e Zd ZdZdZdS )ÚYieldsSectionz0Parser for numpydoc generator "yields" sections.TN)r+   r,   r-   r.   rQ   r   r   r   r   rT   ã   s    rT   c                   @   ó(   e Zd ZdZdedeje fdd„ZdS )ÚDeprecationSectionz3Parser for numpydoc "deprecation warning" sections.r(   r   c                 c   sP   � |j ddd�d d g ^}}}|d urtt |¡ƒ}t| jg|t|ƒd�V  d S )NÚ
r   )ÚsepÚmaxsplit)rE   r)   Úversion)Úsplitr   r;   r<   r   r"   )r$   r(   rZ   ÚdescÚ_r   r   r   r*   ì   s   €ÿzDeprecationSection.parseN)	r+   r,   r-   r.   r/   r1   r2   r   r*   r   r   r   r   rV   é   s    rV   c                   @   rU   )ÚExamplesSectiona·  Parser for numpydoc examples sections.

    E.g. any section that looks like this:
        >>> import numpy.matlib
        >>> np.matlib.empty((2, 2))    # filled with random data
        matrix([[  6.76425276e-320,   9.79033856e-307], # random
                [  7.39337286e-309,   3.22135945e-309]])
        >>> np.matlib.empty((2, 2), dtype=int)
        matrix([[ 6600475,        0], # random
                [ 6586976, 22740995]])
    r(   r   c                 c   s¢   � t |ƒ ¡  ¡ }|rOg }g }|r#|d  d¡sn
| | d¡¡ |s|r7|d  d¡r-n
| | d¡¡ |s%t| jg|rBd |¡ndd |¡d�V  |sdS dS )zÄParse ``DocstringExample`` objects from the body of this section.

        :param text: section body text. Should be cleaned with
                     ``inspect.cleandoc`` before parsing.
        r   z>>>rW   N)Úsnippetr)   )	r   r   Ú
splitlinesÚ
startswithÚappendÚpopr   r"   Újoin)r$   r(   ÚlinesZsnippet_linesZdescription_linesr   r   r   r*     s*   €ýýýõzExamplesSection.parseN)	r+   r,   r-   r.   r/   r1   r2   r   r*   r   r   r   r   r^   ÷   s    r^   Ú
ParametersÚparamÚParamsÚ	ArgumentsÚArgsúOther ParametersÚother_paramzOther ParamszOther Argumentsz
Other ArgsÚReceivesÚreceivesZReceiveÚRaisesÚraisesÚRaiseÚWarnsÚwarnsZWarnÚ
AttributesÚ	attributeÚ	AttributeÚReturnsÚreturnsÚReturnÚYieldsÚyieldsÚYieldÚExamplesÚexamplesÚExampleZWarningsÚwarningsÚWarningzSee AlsoZsee_alsoZRelatedZNotesZnotesZNoteZ
ReferencesÚ
referencesZ	ReferenceÚ
deprecatedÚdeprecationc                   @   s^   e Zd ZdZddejejeef  fdd„Z	dd„ Z
defd	d
„Zdeje defdd„ZdS )ÚNumpydocParserz%Parser for numpydoc-style docstrings.NÚsectionsc                 C   s$   |pt }dd„ |D ƒ| _|  ¡  dS )z[Setup sections.

        :param sections: Recognized sections or None to defaults.
        c                 S   s   i | ]}|j |“qS r   r?   ©Ú.0Úsr   r   r   Ú
<dictcomp>I  s    z+NumpydocParser.__init__.<locals>.<dictcomp>N)ÚDEFAULT_SECTIONSr†   Ú_setup)r$   r†   r   r   r   r%   C  s   zNumpydocParser.__init__c                 C   s,   t jd dd„ | j ¡ D ƒ¡t jd�| _d S )Nú|c                 s   s   � | ]}|j V  qd S r#   )r'   r‡   r   r   r   Ú	<genexpr>N  s   € z(NumpydocParser._setup.<locals>.<genexpr>r   )ÚreÚcompilerd   r†   ÚvaluesÚMÚ	titles_rer@   r   r   r   rŒ   L  s   þzNumpydocParser._setupÚsectionc                 C   s   || j |j< |  ¡  dS )zLAdd or replace a section.

        :param section: The new section.
        N)r†   r!   rŒ   )r$   r”   r   r   r   Úadd_sectionR  s   zNumpydocParser.add_sectionr(   r   c                 C   s$  t tjd�}|s
|S t |¡}| j |¡}|r(|d| ¡ … }|| ¡ d… }n|}d}| dd¡}|d p7d|_	t
|ƒdkrX|d pDd}| d¡|_| d¡|_| ¡ pVd|_t| j |¡ƒD ]/\}}tdd	„ | ¡ D ƒƒ}	| j|	 }
| ¡ }|dur€| ¡ nd}|j |
 |||… ¡¡ q`|S )
zaParse the numpy-style docstring into its components.

        :returns: parsed docstring
        )ÚstyleNÚ rW   r   r   z

c                 s   s   � | ]	}|d ur|V  qd S r#   r   )rˆ   Úgr   r   r   rŽ   |  s   € z'NumpydocParser.parse.<locals>.<genexpr>)r   r   ÚNUMPYDOCr;   r<   r“   rN   r9   r[   Úshort_descriptionr   ra   Úblank_after_short_descriptionÚendswithÚblank_after_long_descriptionr   Úlong_descriptionr   r8   r   Úgroupsr†   r   ÚmetaÚextendr*   )r$   r(   Úretr=   Ú
desc_chunkÚ
meta_chunkÚpartsÚlong_desc_chunkZ	nextmatchr!   Úfactoryr9   r   r   r   r   r*   [  s4   
ÿ
zNumpydocParser.parser#   )r+   r,   r-   r.   r1   ÚOptionalÚDictr/   r    r%   rŒ   r•   r   r*   r   r   r   r   r…   @  s     		r…   r(   c                 C   s   t ƒ  | ¡S )zYParse the numpy-style docstring into its components.

    :returns: parsed docstring
    )r…   r*   )r(   r   r   r   r*   ˆ  s   r*   z    Ú	docstringÚrendering_styleÚindentc           
         sà  dt jtttf f‡ ‡fdd„‰dtdt jt j f‡‡fdd„}g ‰| jr+ˆ 	| j¡ | j
r3ˆ 	d¡ | jrbd	}| jjrE|d
| jj› �7 }| jjrP| jj ¡ }ng }dˆ › �}ˆ 	| |g| ¡¡ | jrkˆ 	| j¡ | jrsˆ 	d¡ |ddd„ | jp|g D ƒƒ |ddd„ | jp‰g D ƒƒ |ddd„ | jp–g D ƒƒ |ddd„ | jp£g D ƒƒ | jrÈ| jsÈ| j}ˆ 	|r¶dnd¡ ˆ 	dtˆd ƒ ¡ ˆ|ƒ |ddd„ | jpÑg D ƒƒ |ddd„ | jpÞg D ƒƒ |ddd„ | jpëg D ƒƒ |ddd„ | jpøg D ƒƒ t| jƒdk�r.ˆ 	d¡ ˆ 	d ¡ ˆ 	d!¡ | jD ]}|j�r"ˆ 	|j¡ |j�r,ˆ 	|j¡ �q| jD ]9}	t|	tttttfƒ�r@�q1ˆ 	d¡ ˆ 	|	jd  d"d¡ ¡ ¡ ˆ 	dt|	jd ƒ ¡ |	j�riˆ 	|	j¡ �q1d ˆ¡S )#a  Render a parsed docstring into docstring text.

    :param docstring: parsed docstring representation
    :param rendering_style: the style to render docstrings
    :param indent: the characters used as indentation in the docstring string
    :returns: docstring text
    Úonec                    sÖ   t | tƒr	| j}nt | tƒr| j}nd }| jr"|r"|d| j› �7 }n| jr)| j}n|s-d}t | tƒrL| jdvr@|d| j› �7 }n| jsH| jdkrL|d7 }| jrddˆ › � 	|g| j 
¡  ¡}ˆ |¡ d S ˆ |¡ d S )Nz : r—   )NÚNonez
, default=r®   z
, optionalrW   )Ú
isinstancer   rF   r
   rR   rG   rI   rH   r)   rd   r`   rb   )r­   ÚheadÚbody)r¬   r¥   r   r   Úprocess_onež  s(   




zcompose.<locals>.process_onerC   rE   c                    sH   |r ˆ   d¡ ˆ   | ¡ ˆ   dtˆ d ƒ ¡ |D ]}ˆ|ƒ qd S d S )Nr—   r&   éÿÿÿÿ)rb   r   )rC   rE   Úarg)r¥   r²   r   r   Úprocess_sect¾  s   


ûzcompose.<locals>.process_sectr—   z.. deprecated::ú rW   rf   c                 S   ó   g | ]}|j d  dkr|‘qS )r   rg   ©rE   ©rˆ   Úitemr   r   r   Ú
<listcomp>Þ  ó    zcompose.<locals>.<listcomp>rt   c                 S   r·   )r   ru   r¸   r¹   r   r   r   r»   ã  ó
    þrw   c                 S   s   g | ]}|j s|‘qS r   ©rQ   r¹   r   r   r   r»   ì  s    ýÿrz   c                 S   s   g | ]}|j r|‘qS r   r¾   r¹   r   r   r   r»   õ  s    r&   r³   rm   c                 S   r·   )r   rn   r¸   r¹   r   r   r   r»      r½   rk   c                 S   r·   )r   rl   r¸   r¹   r   r   r   r»   	  r½   ro   c                 S   r·   )r   rp   r¸   r¹   r   r   r   r»     r¼   rr   c                 S   r·   )r   rs   r¸   r¹   r   r   r   r»     r¼   r   r}   z--------r]   ) r1   ÚUnionr   r
   r	   r/   ÚListÚAnyrš   rb   r›   r„   rZ   r)   r`   rd   rž   r�   ÚparamsÚmany_returnsrx   r   rp   r~   r_   r    r¯   r   r   rE   Úreplacer!   )
rª   r«   r¬   rµ   ÚfirstÚrestrX   r¢   Úexampler    r   )r¬   r¥   r²   r   Úcompose�  s¾   ÿ  


þþþ	þþ	þþþ	þþ	þþ



€
ûþ

€
rÈ   r#   )-r.   r;   r   r�   Útypingr1   Útextwrapr   Úcommonr   r   r   r   r   r	   r
   r   r   r2   r   r/   r¨   r   r�   r’   r7   rJ   rK   rL   rM   rS   r    r3   r>   rB   rO   rP   rT   rV   r^   r‹   r…   r*   ÚCOMPACTrÈ   r   r   r   r   Ú<module>   sÐ    ,

	ÿÿ
!0&ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá#Hüþýüû