
    
`ip>              	          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 dYdej        dej        fdZd	edej        e         fd
Z ej        dej                  Z ej        d          Z ej        d          Z ej        d          Z ej        d          Z G d d          Z G d de          Z G d de          Z  G d de          Z! G d de          Z" G d de          Z# G d de#          Z$ G d d e           Z% G 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!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          Z' G dP dQ          Z(dRede	fdSZ)ej*        dTfdUe	dVedWedefdXZ+dS )Zz_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                 ~    t          j        |           \  }}t          |d            t          j        |||          S )N)	fillvalue)	itertoolsteenextzip_longest)r   endleftrights       m/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/docstring_parser/numpydoc.py	_pairwiser      s=    -))KD% u<<<<    stringc                 X    |                                  } t          |           dk    r| S d S )Nr   )striplen)r   s    r   
_clean_strr       s(    \\^^F
6{{Q4r   z	^[^\s].*$flagsz(^(?P<name>.*?)(?:\s*:\s*(?P<type>.*?))?$z)(?P<type>.*?)(?:, optional|\(optional\))$z@(?<!\S)[Dd]efault(?: is | = |: |s to |)\s*(?P<value>[\w\-\.]*\w)z(^(?:(?P<name>.*?)\s*:\s*)?(?P<type>.*?)$c                   h    e Zd ZdZdededdfdZedefd            Zdedej	        e
         f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                 "    || _         || _        d S N)r%   r&   )selfr%   r&   s      r   __init__zSection.__init__=   s    
r   c                 L    dt          | j                  z  }d| j         d| dS )zRegular 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)   dashess     r   title_patternzSection.title_patternA   s1     s4:&4TZ444444r   textc              #   V   K   t          | j        gt          |                    V  dS )zParse ``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/   s     r   parsezSection.parseK   s3       TXJJt4D4DEEEEEEEEr   )__name__
__module____qualname____doc__strr*   propertyr.   TIterabler   r2    r   r   r$   r$   3   s         c       5s 5 5 5 X5F# F!*]"; F F F F F Fr   r$   c                   L    e Zd ZdZdededefdZdedej        e         fdZ	dS )	
_KVSectionzBase 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                     d S r(   r;   r)   r&   r>   s      r   _parse_itemz_KVSection._parse_item_   s    r   r/   c              #   J  K   t          t                              |                    D ]x\  }}|                                }||                                nd }|||         }|                     |                                t          j        |                    V  yd S )N)r&   r>   )	r   KV_REGEXfinditerr   startrA   groupinspectcleandoc)r)   r/   match
next_matchrE   r   r>   s          r   r2   z_KVSection.parseb   s      !*8+<+<T+B+B!C!C 	 	E:IIKKE(2(>*""$$$DCsOE""KKMM)9%)@)@ #      		 	r   N)
r3   r4   r5   r6   r7   r   rA   r9   r:   r2   r;   r   r   r=   r=   T   sp         s 3 =    # !*]";      r   r=   c                   .    e Zd ZdZedefd            ZdS )_SphinxSectionzBase parser for numpydoc sections with sphinx-style syntax.

    E.g. sections that look like this:
        .. title:: something
            possibly over multiple lines
    r   c                     d| j          dS )Nz	^\.\.\s*(z)\s*::r%   r)   s    r   r.   z_SphinxSection.title_patternt   s    .DJ....r   N)r3   r4   r5   r6   r8   r7   r.   r;   r   r   rL   rL   l   sE          /s / / / X/ / /r   rL   c                   &    e Zd ZdZdededefdZdS )ParamSectionzParser 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&   r>   r   c                    t                               |          }d x}x}}|b|                    d          }|                    d          }|6t                              |          }||                    d          }d}nd}d }t	          |          dk    r1t
                              |          }	|	|	                    d          }t          | j        |gt          |          ||||          S )NnametypeTFr   r>   )argsr1   arg_name	type_nameis_optionaldefault)
PARAM_KEY_REGEXrI   rF   PARAM_OPTIONAL_REGEXr   PARAM_DEFAULT_REGEXsearchr	   r&   r    )
r)   r&   r>   rI   rV   rW   rX   optional_matchrY   default_matchs
             r   rA   zParamSection._parse_item   s   %%c**-1119{{{6**HF++I$!5!;!;I!F!F!- . 4 4V < <I"&KK"'Ku::>>/66u==M('--g66(H%"5))#
 
 
 	
r   N)r3   r4   r5   r6   r7   r	   rA   r;   r   r   rQ   rQ   y   sG         
s 
3 
> 
 
 
 
 
 
r   rQ   c                   &    e Zd ZdZdededefdZdS )RaisesSectionzParser for numpydoc raises sections.

    E.g. any section that looks like this:
        ValueError
            A description of what might raise ValueError
    r&   r>   r   c                 x    t          | j        |gt          |          t          |          dk    r|nd           S )Nr   )rU   r1   rW   )r
   r&   r    r   r@   s      r   rA   zRaisesSection._parse_item   sB    (C"5)) XX\\cct
 
 
 	
r   N)r3   r4   r5   r6   r7   r
   rA   r;   r   r   ra   ra      sG         
s 
3 
? 
 
 
 
 
 
r   ra   c                   *    e Zd ZdZdZdededefdZdS )ReturnsSectionzParser 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&   r>   r   c                     t                               |          }|+|                    d          }|                    d          }nd }d }t          | j        gt          |          || j        |          S )NrS   rT   )rU   r1   rW   is_generatorreturn_name)RETURN_KEY_REGEXrI   rF   r   r&   r    rf   )r)   r&   r>   rI   rg   rW   s         r   rA   zReturnsSection._parse_item   s~     &&s++++f--KF++IIKI("5))*#
 
 
 	
r   N)r3   r4   r5   r6   rf   r7   r   rA   r;   r   r   rd   rd      sO          L
s 
3 
3C 
 
 
 
 
 
r   rd   c                       e Zd ZdZdZdS )YieldsSectionz0Parser for numpydoc generator "yields" sections.TN)r3   r4   r5   r6   rf   r;   r   r   rj   rj      s        ::LLLr   rj   c                   8    e Zd ZdZdedej        e         fdZdS )DeprecationSectionz3Parser for numpydoc "deprecation warning" sections.r/   r   c              #      K   |                     dd          d d gz   ^}}}|!t          t          j        |                    }t	          | j        g|t          |                    V  d S )N
r   )sepmaxsplit)rU   r1   version)splitr    rG   rH   r   r&   )r)   r/   rq   desc_s        r   r2   zDeprecationSection.parse   s       JJ4!J<<d|Kg.t4455D!(z'7J7J
 
 
 	
 	
 	
 	
 	
r   N)	r3   r4   r5   r6   r7   r9   r:   r   r2   r;   r   r   rl   rl      sD        ==
# 
!*-@"A 
 
 
 
 
 
r   rl   c                   8    e Zd ZdZdedej        e         fdZdS )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              #   ,  K   t          |                                                                          }|rg }g }|rF|d                             d          sn*|                    |                    d                     |F|rF|d                             d          rn*|                    |                    d                     |Ft          | j        g|rd                    |          ndd                    |                    V  |dS dS )zParse ``DocstringExample`` objects from the body of this section.

        :param text: section body text. Should be cleaned with
                     ``inspect.cleandoc`` before parsing.
        r   z>>>rn   N)snippetr1   )	r   r   
splitlines
startswithappendpopr   r&   join)r)   r/   linessnippet_linesdescription_liness        r   r2   zExamplesSection.parse   sK      t""$$//11 	M " 3Qx**511 $$UYYq\\222  3  78&&u-- !((1666  7 #
4AK		-000t II&788       	 	 	 	 	r   N)	r3   r4   r5   r6   r7   r9   r:   r   r2   r;   r   r   rv   rv      sG        
 
# !*]";      r   rv   
ParametersparamParams	ArgumentsArgsOther Parametersother_paramzOther ParamszOther Argumentsz
Other ArgsReceivesreceivesReceiveRaisesraisesRaiseWarnswarnsWarn
Attributes	attribute	AttributeReturnsreturnsReturnYieldsyieldsYieldExamplesexamplesExampleWarningswarningsWarningzSee Alsosee_alsoRelatedNotesnotesNote
References
references	Reference
deprecateddeprecationc                   r    e Zd ZdZddej        ej        eef                  fdZ	d Z
defdZded	efd
ZdS )NumpydocParserz%Parser for numpydoc-style docstrings.Nsectionsc                 b    |pt           }d |D             | _        |                                  dS )z[Setup sections.

        :param sections: Recognized sections or None to defaults.
        c                     i | ]
}|j         |S r;   rN   .0ss     r   
<dictcomp>z+NumpydocParser.__init__.<locals>.<dictcomp>6  s    666!666r   N)DEFAULT_SECTIONSr   _setup)r)   r   s     r   r*   zNumpydocParser.__init__0  s5    
 //66X666r   c                     t          j        d                    d | j                                        D                       t           j                  | _        d S )N|c              3   $   K   | ]}|j         V  d S r(   )r.   r   s     r   	<genexpr>z(NumpydocParser._setup.<locals>.<genexpr>;  s$      FF!aoFFFFFFr   r!   )recompiler}   r   valuesM	titles_rerO   s    r   r   zNumpydocParser._setup9  sO    IIFFt}/C/C/E/EFFFFF$
 
 
r   sectionc                 L    || j         |j        <   |                                  dS )zLAdd or replace a section.

        :param section: The new section.
        N)r   r%   r   )r)   r   s     r   add_sectionzNumpydocParser.add_section?  s#     (/gm$r   r/   r   c                    t          t          j                  }|s|S t          j        |          }| j                            |          }|r9|d|                                         }||                                d         }n|}d}|                    dd          }|d         pd|_	        t          |          dk    rY|d         pd}|                    d          |_        |                    d          |_        |                                pd|_        t#          | j                            |                    D ]\  }}t'          d |                                D                       }	| j        |	         }
|                                }||                                nd}|j                            |
                    |||                              |S )	zaParse the numpy-style docstring into its components.

        :returns: parsed docstring
        )styleN rn   r   r   z

c              3      K   | ]}||V  	d S r(   r;   )r   gs     r   r   z'NumpydocParser.parse.<locals>.<genexpr>i  s"      DDqammmmmDDr   )r   r   NUMPYDOCrG   rH   r   r]   rE   rr   short_descriptionr   rz   blank_after_short_descriptionendswithblank_after_long_descriptionr   long_descriptionr   rD   r   groupsr   r   metaextendr2   )r)   r/   retrI   
desc_chunk
meta_chunkpartslong_desc_chunk	nextmatchr%   factoryrE   r   s                r   r2   zNumpydocParser.parseH  s   
 n5666 	J %% %%d++ 	oo.Jekkmmoo.JJJJ   q)) %a 0Du::>>#Ahn"O0?0J0J1 1C- 0?/G/G/O/OC,#2#8#8#:#:#BdC  )$.*A*A**M*M N N 	B 	BE9DDELLNNDDDDDEmE*G IIKKE'0'<)//###$CHOOGMM*U3Y*?@@AAAA
r   r(   )r3   r4   r5   r6   r9   OptionalDictr7   r$   r*   r   r   r   r2   r;   r   r   r   r   -  s        // AF3<,@!A    
 
 
7    *# *) * * * * * *r   r   r/   c                 D    t                                          |           S )zYParse the numpy-style docstring into its components.

    :returns: parsed docstring
    )r   r2   )r/   s    r   r2   r2   u  s    
 !!$'''r   z    	docstringrendering_styleindentc                 4  	
 dt           j        t          t          t          f         f	fd
dt
          dt           j        t           j                 f	
fd}g 	| j        r		                    | j                   | j
        r		                    d           | j        r~d}| j        j        r|d| j        j         z  }| j        j        r| j        j                                        }ng }d	 }		                    |                    |g|z                        | j        r		                    | j                   | j        r		                    d            |d
d | j        pg D                         |dd | j        pg D                         |dd | j        pg D                         |dd | j        pg D                        | j        r]| j        sV| j        }		                    |rdnd           		                    dt+          	d                   z              
|            |dd | j        pg D                         |dd | j        pg D                         |dd | j        pg D                         |dd | j        pg D                        | j        D ]}t1          |t2          t          t          t          f          r+		                    d           		                    |j        d                             dd                                                     		                    dt+          |j        d                   z             |j        r		                    |j                   d	                    	          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                    t          | t                    r| j        }nt          | t                    r| j        }nd }| j        r|r|d| j         z  }n| j        r| j        }n|sd}t          | t                    r| j        r|dz  }| j        rJd                     |g| j        	                                z             }
                    |           d S 
                    |           d S )Nz : r   z
, optionalrn   )
isinstancer	   rV   r   rg   rW   rX   r1   r}   ry   r{   )r   headbodyr   r   s      r   process_onezcompose.<locals>.process_one  s    c>** 	<DD-.. 	?DDD= 	T 	)#-)))DD] 	=DD 	Dc>** 	!s 	!L D? 	 ==%%tfs/I/I/K/K&KLLDLLLLr   rS   rU   c                     |re                     d                                |                                 dt          d                   z             |D ]} |           d S d S )Nr   r,   )r{   r   )rS   rU   argr   r   s      r   process_sectzcompose.<locals>.process_sect  s     	!LLLLLLs59~~-... ! !C    	! 	!! !r   r   z.. deprecated:: rn   r   c                 4    g | ]}|j         d          dk    |S )r   r   rU   r   items     r   
<listcomp>zcompose.<locals>.<listcomp>  (    LLL$DIaLG4K4K4K4K4Kr   r   c                 4    g | ]}|j         d          dk    |S )r   r   r   r   s     r   r   zcompose.<locals>.<listcomp>  s3     	
 	
 	
y|{** ***r   r   c                      g | ]}|j         	|S r;   rf   r   s     r   r   zcompose.<locals>.<listcomp>  s1     	
 	
 	
$	
	
 	
 	
r   r   c                      g | ]}|j         	|S r;   r   r   s     r   r   zcompose.<locals>.<listcomp>  s     LLL$$:KLLLLr   r,   r   r   c                 4    g | ]}|j         d          dk    |S )r   r   r   r   s     r   r   zcompose.<locals>.<listcomp>  s3     	
 	
 	
y|z)) )))r   r   c                 4    g | ]}|j         d          dk    |S )r   r   r   r   s     r   r   zcompose.<locals>.<listcomp>  s3     	
 	
 	
y|},, ,,,r   r   c                 4    g | ]}|j         d          dk    |S )r   r   r   r   s     r   r   zcompose.<locals>.<listcomp>  s(    MMM$DIaLH4L4L4L4L4Lr   r   c                 4    g | ]}|j         d          dk    |S )r   r   r   r   s     r   r   zcompose.<locals>.<listcomp>  r   r   r   rt   )r9   Unionr	   r   r
   r7   ListAnyr   r{   r   r   rq   r1   ry   r}   r   r   paramsmany_returnsr   r   r   r   r   r   rU   replacer%   )r   r   r   r   firstrestro   r   r   r   r   s     `      @@r   composer   }  s   W^%5FG      4!3 !afQUm ! ! ! ! ! ! ! E" 2Y0111. R 	/! ( 	98.6888E , 	(4??AADDD6mmSXXugn--...! 1Y/000- RLLL)*0bLLL  
 L	
 	
!(.B	
 	
 	
   L	
 	
!.4"	
 	
 	
   LLL)06BLLL  
  !7 3XX)444S3uRy>>)***CL	
 	
!(.B	
 	
 	
   L	
 	
!(.B	
 	
 	
   LMM)*0bMMM  
 LLL)*0bLLL  
  + +# 	
 
 		 RTYq\))#r2288::;;;S3ty|,,,--- 	+LL)***99Ur   r(   ),r6   rG   r   r   typingr9   textwrapr   commonr   r   r   r   r	   r
   r   r   r   r:   r   r7   r   r    r   r   rC   rZ   r[   r\   rh   r$   r=   rL   rQ   ra   rd   rj   rl   rv   r   r   r2   COMPACTr   r;   r   r   <module>r     sb   
      				          
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
= =
 = = = = =s qz#     2:l"$///"*HII!rz"NOO  !bjG   2:IJJ F F F F F F F FB       0
/ 
/ 
/ 
/ 
/W 
/ 
/ 
/&
 &
 &
 &
 &
: &
 &
 &
R
 
 
 
 
J 
 
 
 
 
 
 
 
Z 
 
 
<    N   
 
 
 
 
 
 
 
# # # # #g # # #L Lw'' L7##  Lg&&  L!!	 
 L#]33  L//  L"M22  L}--  LZ((  LJ''  M(H%%  M'8$$  M'7##  M&'""  L{++   Lk**! " N9i((# $ N8Y''% & M(H%%' ( M'8$$) * OJ
+++ , OIz**- . GJ
##/ 0 GIz""1 2 GJ
##3 4 GIz""5 6 GGW7 8 GFG9 : GL,''; < GK&&= > |]33?  FE E E E E E E EP( (	 ( ( ( ( '5&<	W WW $W 	W
 	W W W W W Wr   