
    gI4                       d dl mZ d dlmZ d dlmZ erd dlmZmZ d dlm	Z	  G d d      Z
 G d d	e
      Z G d
 de
      Z G d de
      Z G d de
      Z G d de
      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#      Z G d$ d%e      Z G d& d'e      Z G d( d)e      Z G d* d+e      Z G d, d-e      Z G d. d/e      Z G d0 d1e      Z G d2 d3e      Z  G d4 d5e      Z! G d6 d7e      Z" G d8 d9e      Z# G d: d;e      Z$ G d< d=e      Z% G d> d?e      Z& G d@ dAe      Z'yB)C    )annotations)TYPE_CHECKING)DocstringSectionKind)AnyLiteral)Exprc                  &    e Zd ZdZddddZddZy)DocstringElementz8This base class represents annotated, nameless elements.N
annotationc               "    || _         	 || _        y)zInitialize the element.

        Parameters:
            annotation: The element annotation, if any.
            description: The element description.
        Ndescriptionr   )selfr   r   s      N/var/www/openai/venv/lib/python3.12/site-packages/_griffe/docstrings/models.py__init__zDocstringElement.__init__   s     !,&-7%    c                4    | j                   | j                  dS )Return this element's data as a dictionary.

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r   r   r   )r   kwargss     r   as_dictzDocstringElement.as_dict   s     //++
 	
r   )r   strr   str | Expr | NonereturnNoner   r   r   zdict[str, Any])__name__
__module____qualname____doc__r   r    r   r   r
   r
      s    BLP 
&
r   r
   c                  J     e Zd ZdZddd	 	 	 	 	 	 	 	 	 d fdZd fdZ xZS )DocstringNamedElementz5This base class represents annotated, named elements.N)r   valuec               F    t         |   ||       || _        	 || _        y)zInitialize the element.

        Parameters:
            name: The element name.
            description: The element description.
            annotation: The element annotation, if any.
            value: The element value, as a string.
        r   N)superr   namer%   )r   r(   r   r   r%   	__class__s        r   r   zDocstringNamedElement.__init__1   s+      	[ZH	!&
'r   c                x    d| j                   it        |   di |}| j                  | j                  |d<   |S )r   r(   r%   r"   )r(   r'   r   r%   )r   r   baser)   s      r   r   zDocstringNamedElement.as_dictG   s@     		?UW_%>v%>?::! JJDMr   )
r(   r   r   r   r   r   r%   
str | Noner   r   r   )r   r   r    r!   r   r   __classcell__r)   s   @r   r$   r$   .   sM    ? )- (( 	(
 &( ( 
(, r   r$   c                      e Zd ZdZedd       Zej                  dd       Zed	d       Zej                  d
d       Zy)DocstringAdmonitionz$This class represents an admonition.c                    | j                   S )zThe kind of this admonition.r   r   s    r   kindzDocstringAdmonition.kindY        r   c                    || _         y Nr   r   r%   s     r   r3   zDocstringAdmonition.kind^   	    r   c                    | j                   S )z The contents of this admonition.r   r2   s    r   contentszDocstringAdmonition.contentsb   s     r   c                    || _         y r6   r:   r7   s     r   r;   zDocstringAdmonition.contentsg   s
     r   Nr   r   )r%   z
str | Exprr   r   r   r   r%   r   r   r   )r   r   r    r!   propertyr3   setterr;   r"   r   r   r0   r0   V   s[    .  
[[        __! !r   r0   c                  H    e Zd ZdZedd       Zej                  dd       Zy)DocstringDeprecatedz3This class represents a documented deprecated item.c                    | j                   S )z The version of this deprecation.r   r2   s    r   versionzDocstringDeprecated.versiono   r4   r   c                    || _         y r6   r   r7   s     r   rE   zDocstringDeprecated.versiont   r8   r   Nr>   r?   )r   r   r    r!   r@   rE   rA   r"   r   r   rC   rC   l   s/    =  ^^   r   rC   c                      e Zd ZdZy)DocstringRaisez/This class represents a documented raise value.Nr   r   r    r!   r"   r   r   rH   rH   y       9r   rH   c                      e Zd ZdZy)DocstringWarnz.This class represents a documented warn value.NrI   r"   r   r   rL   rL   }   s    8r   rL   c                      e Zd ZdZy)DocstringReturnz0This class represents a documented return value.NrI   r"   r   r   rN   rN      s    :r   rN   c                      e Zd ZdZy)DocstringYieldz/This class represents a documented yield value.NrI   r"   r   r   rP   rP      rJ   r   rP   c                      e Zd ZdZy)DocstringReceivez1This class represents a documented receive value.NrI   r"   r   r   rR   rR      s    ;r   rR   c                  H    e Zd ZdZedd       Zej                  dd       Zy)DocstringParameterz5This class represent a documented function parameter.c                    | j                   S )z$The default value of this parameter.r%   r2   s    r   defaultzDocstringParameter.default   s     zzr   c                    || _         y r6   rV   r7   s     r   rW   zDocstringParameter.default   s	    
r   N)r   r,   r?   )r   r   r    r!   r@   rW   rA   r"   r   r   rT   rT      s/    ?  ^^ r   rT   c                      e Zd ZdZy)DocstringAttributez:This class represents a documented module/class attribute.NrI   r"   r   r   rZ   rZ      s    Dr   rZ   c                  "    e Zd ZdZedd       Zy)DocstringFunctionz,This class represents a documented function.c                    | j                   S )zThe function signature.r   r2   s    r   	signaturezDocstringFunction.signature   r4   r   Nr=   r   r   r    r!   r@   r^   r"   r   r   r\   r\      s    6 r   r\   c                  "    e Zd ZdZedd       Zy)DocstringClassz)This class represents a documented class.c                    | j                   S )zThe class signature.r   r2   s    r   r^   zDocstringClass.signature   r4   r   Nr=   r_   r"   r   r   ra   ra      s    3 r   ra   c                      e Zd ZdZy)DocstringModulez*This class represents a documented module.NrI   r"   r   r   rd   rd      s    4r   rd   c                  8    e Zd ZU dZded<   	 dd	dZd
dZddZy)DocstringSectionz*This class represents a docstring section.r   r3   Nc                "    || _         	 d| _        y)z[Initialize the section.

        Parameters:
            title: An optional title.
        N)titler%   )r   rh   s     r   r   zDocstringSection.__init__   s     "'
 
 r   c                ,    t        | j                        S )z*Whether this section has a true-ish value.)boolr%   r2   s    r   __bool__zDocstringSection.__bool__   s    DJJr   c                    t        | j                  d      r | j                  j                  di |}n| j                  }| j                  j                  |d}| j                  r| j                  |d<   |S )zReturn this section's data as a dictionary.

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r   )r3   r%   rh   r"   )hasattrr%   r   r3   rh   )r   r   serialized_valuer+   s       r   r   zDocstringSection.as_dict   sb     4::y)1tzz11;F;#zz		2BC:: JJDMr   r6   )rh   r,   r   r   )r   rj   r   )r   r   r    r!   __annotations__r   rk   r   r"   r   r   rf   rf      s    4
	! r   rf   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionTextz%This class represents a text section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section text.
            title: An optional title.
        Nr'   r   r%   r   r%   rh   r)   s      r   r   zDocstringSectionText.__init__   s     	
r   r6   )r%   r   rh   r,   r   r   )
r   r   r    r!   r   textr3   ro   r   r-   r.   s   @r   rq   rq      s!    /!5!:!:D
:   r   rq   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionParametersz+This class represents a parameters section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section parameters.
            title: An optional title.
        Nrs   rt   s      r   r   z#DocstringSectionParameters.__init__        	/4
r   r6   )r%   zlist[DocstringParameter]rh   r,   r   r   )
r   r   r    r!   r   
parametersr3   ro   r   r-   r.   s   @r   rw   rw      s!    5!5!@!@D
@5 5r   rw   c                  4    e Zd ZU dZej
                  Zded<   y)DocstringSectionOtherParametersz2This class represents an other parameters section.r   r3   N)r   r   r    r!   r   other_parametersr3   ro   r"   r   r   r|   r|      s    <!5!F!FD
Fr   r|   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionRaisesz'This class represents a raises section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section exceptions.
            title: An optional title.
        Nrs   rt   s      r   r   zDocstringSectionRaises.__init__       	+0
r   r6   )r%   zlist[DocstringRaise]rh   r,   r   r   )
r   r   r    r!   r   raisesr3   ro   r   r-   r.   s   @r   r   r     !    1!5!<!<D
<1 1r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionWarnsz&This class represents a warns section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section warnings.
            title: An optional title.
        Nrs   rt   s      r   r   zDocstringSectionWarns.__init__  s     	*/
r   r6   )r%   zlist[DocstringWarn]rh   r,   r   r   )
r   r   r    r!   r   warnsr3   ro   r   r-   r.   s   @r   r   r     s!    0!5!;!;D
;0 0r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionReturnsz(This class represents a returns section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section returned items.
            title: An optional title.
        Nrs   rt   s      r   r   z DocstringSectionReturns.__init__(       	,1
r   r6   )r%   zlist[DocstringReturn]rh   r,   r   r   )
r   r   r    r!   r   returnsr3   ro   r   r-   r.   s   @r   r   r   #  !    2!5!=!=D
=2 2r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionYieldsz'This class represents a yields section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section yielded items.
            title: An optional title.
        Nrs   rt   s      r   r   zDocstringSectionYields.__init__8  r   r   r6   )r%   zlist[DocstringYield]rh   r,   r   r   )
r   r   r    r!   r   yieldsr3   ro   r   r-   r.   s   @r   r   r   3  r   r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionReceivesz)This class represents a receives section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section received items.
            title: An optional title.
        Nrs   rt   s      r   r   z!DocstringSectionReceives.__init__H  s     	-2
r   r6   )r%   zlist[DocstringReceive]rh   r,   r   r   )
r   r   r    r!   r   receivesr3   ro   r   r-   r.   s   @r   r   r   C  s!    3!5!>!>D
>3 3r   r   c                  V     e Zd ZU dZej
                  Zded<   	 d	 	 	 	 	 d fdZ xZ	S )DocstringSectionExamplesz*This class represents an examples section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section examples.
            title: An optional title.
        Nrs   rt   s      r   r   z!DocstringSectionExamples.__init__X  s     	jo
r   r6   )r%   zSlist[tuple[Literal[DocstringSectionKind.text, DocstringSectionKind.examples], str]]rh   r,   r   r   )
r   r   r    r!   r   examplesr3   ro   r   r-   r.   s   @r   r   r   S  sG    4!5!>!>D
>
 !pbp p 
	p pr   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionAttributesz,This class represents an attributes section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section attributes.
            title: An optional title.
        Nrs   rt   s      r   r   z#DocstringSectionAttributes.__init__l  ry   r   r6   )r%   zlist[DocstringAttribute]rh   r,   r   r   )
r   r   r    r!   r   
attributesr3   ro   r   r-   r.   s   @r   r   r   g  s!    6!5!@!@D
@5 5r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionFunctionsz2This class represents a functions/methods section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section functions.
            title: An optional title.
        Nrs   rt   s      r   r   z"DocstringSectionFunctions.__init__|  s     	.3
r   r6   )r%   zlist[DocstringFunction]rh   r,   r   r   )
r   r   r    r!   r   	functionsr3   ro   r   r-   r.   s   @r   r   r   w  s!    <!5!?!?D
?4 4r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionClassesz(This class represents a classes section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section classes.
            title: An optional title.
        Nrs   rt   s      r   r   z DocstringSectionClasses.__init__  r   r   r6   )r%   zlist[DocstringClass]rh   r,   r   r   )
r   r   r    r!   r   classesr3   ro   r   r-   r.   s   @r   r   r     s!    2!5!=!=D
=1 1r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionModulesz(This class represents a modules section.r   r3   c                2    t         |   |       || _        y)zInitialize the section.

        Parameters:
            value: The section modules.
            title: An optional title.
        Nrs   rt   s      r   r   z DocstringSectionModules.__init__  r   r   r6   )r%   zlist[DocstringModule]rh   r,   r   r   )
r   r   r    r!   r   modulesr3   ro   r   r-   r.   s   @r   r   r     r   r   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionDeprecatedz+This class represents a deprecated section.r   r3   c                H    t         |   |       t        ||      | _        y)zInitialize the section.

        Parameters:
            version: The deprecation version.
            text: The deprecation text.
            title: An optional title.
        r   N)r'   r   rC   r%   )r   rE   ru   rh   r)   s       r   r   z#DocstringSectionDeprecated.__init__  s!     	*=^b*c
r   r6   )rE   r   ru   r   rh   r,   r   r   )
r   r   r    r!   r   
deprecatedr3   ro   r   r-   r.   s   @r   r   r     s#    5!5!@!@D
@	d 	dr   r   c                  J     e Zd ZU dZej
                  Zded<   dd fdZ xZ	S )DocstringSectionAdmonitionz,This class represents an admonition section.r   r3   c                H    t         |   |       t        ||      | _        y)zInitialize the section.

        Parameters:
            kind: The admonition kind.
            text: The admonition text.
            title: An optional title.
        r   N)r'   r   r0   r%   )r   r3   ru   rh   r)   s       r   r   z#DocstringSectionAdmonition.__init__  s!     	*=[_*`
r   r6   )r3   r   ru   r   rh   r,   r   r   )
r   r   r    r!   r   
admonitionr3   ro   r   r-   r.   s   @r   r   r     s#    6!5!@!@D
@	a 	ar   r   N)(
__future__r   typingr   _griffe.enumerationsr   r   r   _griffe.expressionsr   r
   r$   r0   rC   rH   rL   rN   rP   rR   rT   rZ   r\   ra   rd   rf   rq   rw   r|   r   r   r   r   r   r   r   r   r   r   r   r   r"   r   r   <module>r      s   #   5#(
 
<%, %P!* !,
 * 
 :% :9$ 9;+ ;:* :<, <
. 
E. E- * 5+ 5
% %P +   5!1 5 G&@ G1- 1 0, 0 2. 2 1- 1 3/ 3 p/ p(5!1 5 4 0 4 1. 1 2. 2 d!1 d"a!1 ar   