
    iKj                       d dl mZ d dlZd dlmZmZmZ d dlmZ er$d dl	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ ej*                  ej,                  ej.                  gZed   Z	 ej,                  dg dfej.                  dg dfej*                  dg dfiZ G d ded      Zddddd	 	 	 	 	 	 	 	 	 	 	 ddZ G d ded      Zddddd	 	 	 	 	 	 	 	 	 	 	 ddZy)    )annotationsN)TYPE_CHECKINGLiteral	TypedDict)Parser)GoogleOptions)DocstringSection)NumpyOptions)DocstringStyle)SphinxOptions)	Docstring)
heuristicsmax_sectionsz!\n[ \t]*{0}:([ \t]+.+)?\n[ \t]+.+)args	argumentsparams
parameterszkeyword argszkeyword argumentsz
other argszother argumentszother paramsother parametersraises
exceptionsreturnsyieldsreceivesexamples
attributes	functionsmethodsclassesmoduleswarnswarningsz\n[ \t]*{0}\n[ \t]*---+\n)
deprecatedr   r   r   r   r   r   r    r   r   r   r   r   z&\n[ \t]*:{0}([ \t]+\w+)*:([ \t]+.+)?\n)param	parameterargargumentkeykeywordtypevarivarcvarvartyper   returnrtyper   raiseexcept	exceptionc                  4    e Zd ZU dZded<   	 ded<   	 ded<   y)	PerStyleOptionsz(Per-style options for docstring parsing.r   googler
   numpyr   sphinxN__name__
__module____qualname____doc____annotations__     q/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/griffe/_internal/docstrings/auto.pyr4   r4   i   s     2.-.r?   r4   F)totalr   methodstyle_orderdefaultper_style_optionsc          	         ddl m} |xs i }|xs t        D cg c]  }t        |t              rt        |      n|! }}|dk(  r|D ]y  }t        |   \  }}|D 	cg c]F  }	t        j                  |j                  |	      t        j                  t        j                  z        H }
}	t         fd|
D              su|dfc S  |t        |t
              r|dfS t        |      dfS |dk(  ri }|D ]!  } ||    fi |j                  |i       ||<   # |j                         D ci c]  \  }}|t        |       }}}t!        |j#                               }|D ]  }||   |k(  s|||   fc S  t%        d| d      c c}w c c}	w c c}}w )	a  Infer the parser to use for the docstring.

    The 'heuristics' method uses regular expressions. The 'max_sections' method
    parses the docstring with all parsers specified in `style_order` and returns
    the one who parsed the most sections.

    If heuristics fail, the `default` parser is returned. If multiple parsers
    parsed the same number of sections, `style_order` is used to decide which
    one to return. The `default` parser is never used with the 'max_sections' method.

    Additional options are parsed to the detected parser, if any.

    Parameters:
        docstring: The docstring to parse.
        method: The method to use to infer the parser.
        style_order: The order of the styles to try when inferring the parser.
        default: The default parser to use if the inference fails.
        per_style_options: Additional parsing options per style.

    Returns:
        The inferred parser, and optionally parsed sections (when method is 'max_sections').
    r   )parsersr   c              3  T   K   | ]  }|j                  j                         ! y w)N)searchvalue).0pattern	docstrings     r@   	<genexpr>z(infer_docstring_style.<locals>.<genexpr>   s     K(w7>>)//2(s   %(Nr   zInvalid method 'z'.)#griffe._internal.docstrings.parsersrH   _default_style_order
isinstancestrr   	_patternsrecompileformat
IGNORECASE	MULTILINEanygetitemslenmaxvalues
ValueError)rN   rC   rD   rE   rF   rH   stylerM   replacementsreplacementpatternsstyle_sectionssectionstyle_lengthsr   s   `              r@   infer_docstring_stylerh   t   s   < <)/RS^SvbvSvwSv%Juc$:6%=ESvKw E$-e$4!G\iuiuZe

7>>+68TUiu   K(KKd{" ! "/Z-Hw_cccfU\o_ccc E$2GEN9$a@Q@U@UV[]_@`$aN5! !CQCWCWCYZCYG,CYZ=//12 EU#|3nU333 ! 'xr2
33- x
 [s   $E?AF&F	c                  @    e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   y
)AutoOptionsz"Options for Auto-style docstrings.DocstringDetectionMethodrC   *list[Parser] | list[DocstringStyle] | NonerD   Parser | DocstringStyle | NonerE   PerStyleOptions | NonerF   Nr8   r>   r?   r@   rj   rj      s)    ,$$0;;?++;--/r?   rj   c               |    ddl m} |xs i }t        | ||||      \  }}| || |fi |j                  |i       S |S )a5  Parse a docstring by automatically detecting the style it uses.

    See [`infer_docstring_style`][griffe.infer_docstring_style] for more information
    on the available parameters.

    Parameters:
        docstring: The docstring to parse.
        method: The method to use to infer the parser.
        style_order: The order of the styles to try when inferring the parser.
        default: The default parser to use if the inference fails.
        per_style_options: Additional parsing options per style.

    Returns:
        A list of docstring sections.
    r   )parserB   )rP   rp   rh   r[   )rN   rC   rD   rE   rF   rp   ra   sectionss           r@   
parse_autorr      s\    . :)/R++OE8 YJ):)>)>ub)IJJOr?   )rN   r   rC   rk   rD   rl   rE   rm   rF   rn   r.   z3tuple[Parser | None, list[DocstringSection] | None])rN   r   rC   rk   rD   rl   rE   rm   rF   rn   r.   zlist[DocstringSection])
__future__r   rU   typingr   r   r   griffe._internal.enumerationsr   "griffe._internal.docstrings.googler   "griffe._internal.docstrings.modelsr	   !griffe._internal.docstrings.numpyr
   rP   r   "griffe._internal.docstrings.sphinxr   griffe._internal.modelsr   r7   r5   r6   rQ   rk   rT   r4   rh   rj   rr   r>   r?   r@   <module>r{      sZ   # 	 4 4 0@C>B@1 v}}fllC  ##?@  6 MM,	
8 LL$	
& MM1	
aG	T/iu / (4>B.2048484 %84 <	84
 ,84 .84 984v
0)5 
0  (4>B.204$$ %$ <	$
 ,$ .$ $r?   