
    g                       U d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ erd dlmZ ej(                  ej*                  ej,                  gZed	   Z	 ed
   Z	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 ddZej8                  eej*                  eej(                  eej,                  eiZded<   	 	 	 	 	 	 	 	 ddZy)    )annotations)TYPE_CHECKINGAnyCallableLiteral)parse_google)DocstringSectionDocstringSectionText)parse_numpy)parse_sphinx)Parser)	Docstring)googlenumpysphinxauto)
heuristicsmax_sectionsr   Nmethodstyle_orderdefaultc                   |r!t        |t              r|dfS t        |      dfS |r&|d   }t        |t              r|dfS t        |      dfS y)a>  Infer the parser to use for the docstring.

    [:octicons-heart-fill-24:{ .pulse } Sponsors only](../../../insiders/index.md){ .insiders } &mdash;
    [:octicons-tag-24: Insiders 1.3.0](../../../insiders/changelog.md#1.3.0).

    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.

    For non-Insiders versions, `default` is returned if specified, else the first
    parser in `style_order` is returned. If `style_order` is not specified,
    `None` is returned.

    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.
        **options: Additional parsing options.

    Returns:
        The inferred parser, and optionally parsed sections (when method is 'max_sections').
    Nr   )NN)
isinstancer   )	docstringr   r   r   optionsstyles         O/var/www/openai/venv/lib/python3.12/site-packages/_griffe/docstrings/parsers.pyinfer_docstring_styler       s[    J $Wf5wDPP6'?DPPA"5&1udJJve}dJJ    c               J    t        | f|||d|\  }}|t        | |fi |S |S )a  Parse a docstring by automatically detecting the style it uses.

    [:octicons-heart-fill-24:{ .pulse } Sponsors only](../../../insiders/index.md){ .insiders } &mdash;
    [:octicons-tag-24: Insiders 1.3.0](../../../insiders/changelog.md#1.3.0).

    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.
        **options: Additional parsing options.

    Returns:
        A list of docstring sections.
    r   )r   parse)r   r   r   r   r   r   sectionss          r   
parse_autor$   M   sL    4 ,	
 OE8 Y111Or    z;dict[Parser, Callable[[Docstring], list[DocstringSection]]]parsersc                    |r*t        |t              st        |      }t        |   | fi |S t        | j                        gS )a  Parse the docstring.

    Parameters:
        docstring: The docstring to parse.
        parser: The docstring parser to use. If None, return a single text section.
        **options: The options accepted by the parser.

    Returns:
        A list of docstring sections.
    )r   r   r%   r
   value)r   parserr   s      r   r"   r"   {   s@     &&)F^Fvy4G44 122r    )r   r   r   DocstringDetectionMethodr   *list[Parser] | list[DocstringStyle] | Noner   Parser | DocstringStyle | Noner   r   returnz3tuple[Parser | None, list[DocstringSection] | None])r   r   r   r)   r   r*   r   r+   r   r   r,   list[DocstringSection])r   r   r(   zDocstringStyle | Parser | Noner   r   r,   r-   ) 
__future__r   typingr   r   r   r   _griffe.docstrings.googler   _griffe.docstrings.modelsr	   r
   _griffe.docstrings.numpyr   _griffe.docstrings.sphinxr   _griffe.enumerationsr   _griffe.modelsr   r   r   r   _default_style_orderDocstringStyler)   r   r$   r   r%   __annotations__r"    r    r   <module>r:      sT   # 8 8 2 L 0 2 '( v}}fllC  <= P"#?@  6 (4>B.2** %* <	*
 ,* * 9*` (4>B.2## %# <	#
 ,# # #N KK
MM<
MM<
LL+	H	D 33*3 3 	3r    