
    Jiz"                       d dl mZ d dlZd dlmZmZmZmZ d dl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j0                  ej2                  ej4                  gZed   Z	 ej2                  dg dfej4                  dg dfej0                  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AnyLiteral	TypedDict)warn)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__     r/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/griffe/_internal/docstrings/auto.pyr6   r6   j   s     2.-.rA   r6   F)totalr   methodstyle_orderdefaultper_style_optionsc          	     j    ddl m} |r&|rt        d      t        dt        d       |||d}n|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.
        **options: Deprecated. Use `per_style_options` instead.

    Returns:
        The inferred parser, and optionally parsed sections (when method is 'max_sections').
    r   )parsers2Cannot use both `options` and `per_style_options`.z;`**options` is deprecated. Use `per_style_options` instead.   
stacklevelr7   r8   r9   r   c              3  T   K   | ]  }|j                  j                         ! y w)N)searchvalue).0pattern	docstrings     rB   	<genexpr>z(infer_docstring_style.<locals>.<genexpr>   s     Kw7>>)//2Ks   %(Nr   zInvalid method 'z'.)#griffe._internal.docstrings.parsersrJ   
ValueErrorr   DeprecationWarning_default_style_order
isinstancestrr	   	_patternsrecompileformat
IGNORECASE	MULTILINEanygetitemslenmaxvalues)rU   rE   rF   rG   rH   optionsrJ   stylerT   replacementsreplacementpatternsstyle_sectionssectionstyle_lengthsr   s   `               rB   infer_docstring_stylerq   u   s   B < QRRJL^klm'.GTS^Svbvw%Juc$:6%=EwKw  	#E$-e$4!G\iuZe

7>>+68TUH  K(KKd{"	# "/Z-Hw_cccfU\o_ccc  	bE$2GEN9$a@Q@U@UV[]_@`$aN5!	bCQCWCWCYZG,ZZ=//12  	4EU#|3nU333	4 'xr2
33- x
 [s    $F% 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.DocstringDetectionMethodrE   *list[Parser] | list[DocstringStyle] | NonerF   Parser | DocstringStyle | NonerG   PerStyleOptions | NonerH   Nr:   r@   rA   rB   rs   rs      s)    ,$$0;;?++;--/rA   rs   c                   ddl m} |r&|rt        d      t        dt        d       |||d}n|si }t        | ||||      \  }}| || |fi |j                  |i       S |S )	au  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.
        **options: Deprecated. Use `per_style_options` instead.

    Returns:
        A list of docstring sections.
    r   )parserK   z<`**options` are deprecated. Use `per_style_options` instead.rL   rM   rO   rD   )rW   ry   rX   r   rY   rq   rd   )	rU   rE   rF   rG   rH   ri   ry   rj   sectionss	            rB   
parse_autor{      s    4 : QRRKM_lmn'.GT++OE8 YJ):)>)>ub)IJJOrA   )rU   r   rE   rt   rF   ru   rG   rv   rH   rw   ri   r   r0   z3tuple[Parser | None, list[DocstringSection] | None])rU   r   rE   rt   rF   ru   rG   rv   rH   rw   ri   r   r0   zlist[DocstringSection])"
__future__r   r^   typingr   r   r   r   r#   r   griffe._internal.enumerationsr	   "griffe._internal.docstrings.googler
   "griffe._internal.docstrings.modelsr   !griffe._internal.docstrings.numpyr   rW   r   "griffe._internal.docstrings.sphinxr   griffe._internal.modelsr   r9   r7   r8   rZ   rt   r]   r6   rq   rs   r{   r@   rA   rB   <module>r      sy   # 	 9 9  0@C>B@1 v}}fllC  ##?@  6 MM,	
8 LL$	
& MM1	
aG	T/iu / (4>B.204B4B4 %B4 <	B4
 ,B4 .B4 B4 9B4J
0)5 
0  (4>B.204.. %. <	.
 ,. .. . .rA   