
    %j+                    n   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dS )+    )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                  6    e Zd ZU dZded<   	 ded<   	 ded<   dS )	PerStyleOptionsz(Per-style options for docstring parsing.r   googler
   numpyr   sphinxN__name__
__module____qualname____doc____annotations__     h/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/griffe/_internal/docstrings/auto.pyr4   r4   i   sB         22.-..r?   r4   F)totalr   methodstyle_orderdefaultper_style_options	docstringr   rC   DocstringDetectionMethodrD   *list[Parser] | list[DocstringStyle] | NonerE   Parser | DocstringStyle | NonerF   PerStyleOptions | Noner.   3tuple[Parser | None, list[DocstringSection] | None]c          	     l    ddl m} |pi }d |pt          D             }|dk    rn|D ]A}t          |         \  }fd|D             }t	           fd|D                       r|dfc S B|t          |t                    r|nt          |          dfS |dk    ri }	|D ](} ||          fi |                    |i           |	|<   )d	 |	                                D             }
t          |

                                          }|D ]}|
|         |k    r||	|         fc S t          d
| d          )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   )parsersc                Z    g | ](}t          |t                    rt          |          n|)S r>   )
isinstancestrr   ).0styles     r@   
<listcomp>z)infer_docstring_style.<locals>.<listcomp>   s1    www%Juc$:$:E6%===wwwr?   r   c                    g | ]A}t          j                            |          t           j        t           j        z            BS r>   )recompileformat
IGNORECASE	MULTILINE)rR   replacementpatterns     r@   rT   z)infer_docstring_style.<locals>.<listcomp>   sG       Ze
7>>+668TUU  r?   c              3  L   K   | ]}|                     j                  V  d S )N)searchvalue)rR   r\   rG   s     r@   	<genexpr>z(infer_docstring_style.<locals>.<genexpr>   s1      KKw7>>)/22KKKKKKr?   Nr   c                4    i | ]\  }}|t          |          S r>   )len)rR   rS   sections      r@   
<dictcomp>z)infer_docstring_style.<locals>.<dictcomp>   s$    ZZZGZZZr?   zInvalid method 'z'.)#griffe._internal.docstrings.parsersrN   _default_style_order	_patternsanyrP   r   getitemsmaxvalues
ValueError)rG   rC   rD   rE   rF   rN   rS   replacementspatternsstyle_sectionsstyle_lengthsr   r\   s   `           @r@   infer_docstring_stylerr   t   s   < <;;;;;)/RwwS^SvbvwwwK  	# 	#E$-e$4!G\   iu  H KKKK(KKKKK #d{"""#!/Z-H-H/wwfU\oo_ccc  	b 	bE$2GEN9$a$a@Q@U@UV[]_@`@`$a$aN5!!ZZ>CWCWCYCYZZZ=//1122  	4 	4EU#|33nU33333 4 2222
3
33r?   c                  B    e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   d
S )AutoOptionsz"Options for Auto-style docstrings.rH   rC   rI   rD   rJ   rE   rK   rF   Nr8   r>   r?   r@   rt   rt      sQ         ,,$$$$0;;;;?++++;----//r?   rt   list[DocstringSection]c                   ddl m} |pi }t          | ||||          \  }}| || |fi |                    |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   )re   rw   rr   ri   )rG   rC   rD   rE   rF   rw   rS   sectionss           r@   
parse_autory      s    . :99999)/R++  OE8 uYJJ):)>)>ub)I)IJJJOr?   )rG   r   rC   rH   rD   rI   rE   rJ   rF   rK   r.   rL   )rG   r   rC   rH   rD   rI   rE   rJ   rF   rK   r.   ru   )
__future__r   rV   typingr   r   r   griffe._internal.enumerationsr   "griffe._internal.docstrings.googler   "griffe._internal.docstrings.modelsr	   !griffe._internal.docstrings.numpyr
   re   r   "griffe._internal.docstrings.sphinxr   griffe._internal.modelsr   r7   r5   r6   rf   rH   rg   r4   rr   rt   ry   r>   r?   r@   <module>r      s   # " " " " " 				 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 2@@@@@@CCCCCC>>>>>>BBBBBB@@@@@@111111 v}flC  ##?@  6 M,	
 	
 	
8 L$	
 	
 	
& M1	
 	
 	
aG	T/ / / / /iu / / / / (4>B.20484 84 84 84 84 84v
0 
0 
0 
0 
0)5 
0 
0 
0 
0  (4>B.204$ $ $ $ $ $ $ $r?   