
    g                        U d dl mZ d dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZ d dlmZmZmZ ed   Zdd	 	 	 	 	 	 	 dd	Zdd
Zdg ddfdg ddfdg ddfgZded<   ed        Zy)    )annotationsN)contextmanager)	Signature)AnyCallableLiteralcast)	DocstringDocstringSectionKindObject)googlenumpysphinx)stylec                  | j                   }|di fS t        t        |      }t        |d|xs t	        |      |      }t               5  |j                         }ddd       i }t        d D        d      x}r.|j                  D 	ci c]  }	|	j                  |	j                   }}	d}
t        d |D        d      x}r|j                  }
|
|fS # 1 sw Y   uxY wc c}	w )zExtract the function description and parameter descriptions from a function's docstring.

    Returns:
        A tuple of (main function description, parameter descriptions).
    N    )linenoparserparentc              3  \   K   | ]$  }|j                   t        j                  k(  s!| & y wN)kindr   
parameters.0ps     H/var/www/openai/venv/lib/python3.12/site-packages/pydantic_ai/_griffe.py	<genexpr>z#doc_descriptions.<locals>.<genexpr>"   s#     \h!&&<P<[<[2[1h   ",,c              3  \   K   | ]$  }|j                   t        j                  k(  s!| & y wr   )r   r   textr   s     r   r   z#doc_descriptions.<locals>.<genexpr>&   s#     P1AFF6J6O6O,OQr    )__doc__r	   GriffeObjectr
   _infer_docstring_style_disable_griffe_loggingparsenextvaluenamedescription)funcsigr   docr   	docstringsectionsparamsr   r   	main_descmains               r   doc_descriptionsr4      s     ,,C
{2v ,$F#a0T9OPS9T]cdI	 	"??$ 
# F\h\^bcczc1;1A1AB1AA!&&!--'1ABIPPRVWWtWJJ	f 
#	"
 Cs   	CCCc                \     t         D ]!  \  }} fd|D        }t        |      s|c S  y)z%Simplistic docstring style inference.c              3     K   | ]I  }t        j                  j                  |      t         j                  t         j                  z         K y wr   )researchformat
IGNORECASE	MULTILINE)r   replacementr.   patterns     r   r   z)_infer_docstring_style.<locals>.<genexpr>/   s:      
iuZeBIIgnn[138TUius   AAr   )_docstring_style_patternsany)r.   replacementsr   matchesr=   s   `   @r   r%   r%   ,   s7    (A$u
iu
 w<L )B     z&\n[ \t]*:{0}([ \t]+\w+)*:([ \t]+.+)?\n)param	parameterargargumentkeykeywordtypevarivarcvarvartypereturnsreturnrtyperaisesraiseexcept	exceptionr   z!\n[ \t]*{0}:([ \t]+.+)?\n[ \t]+.+)args	argumentsr1   r   zkeyword argszkeyword argumentsz
other argszother argumentszother paramsother parametersrQ   
exceptionsrN   yieldsreceivesexamples
attributes	functionsmethodsclassesmoduleswarnswarningsr   z\n[ \t]*{0}\n[ \t]*---+\n)
deprecatedr   rW   rN   rY   rZ   rQ   ra   r\   r]   r^   r_   r`   r   z+list[tuple[str, list[str], DocstringStyle]]r>   c               #     K   t         j                  j                         } t         j                  j                  t         j                         d  t         j                  j                  |        y wr   )loggingrootgetEffectiveLevelsetLevelERROR)	old_levels    r   r&   r&      sE      ..0ILL'--(	LL)$s   A0A2)r,   zCallable[..., Any]r-   r   r   zDocstringStyle | NonerO   ztuple[str, dict[str, str]])r.   strrO   DocstringStyle)
__future__r   _annotationsre   r7   
contextlibr   inspectr   typingr   r   r   r	   griffer
   r   r   r$   rl   r4   r%   r>   __annotations__r&    rB   r   <module>ru      s    2  	 %  / / J J45 QU
#,8M<	 	2	
( 	-2 	-	
2 	7< 	%	
 	#mIJ F IX % %rB   