
    -PhG                       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	 d dl
mZ d dlmZmZ d dlmZ d d	lmZmZmZmZmZ d d
lmZ d dlm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* d dl+m,Z,m-Z-  ej.        e/          Z0 ej1        dej2                  Z3 G d d          Z4 G d de4e          Z5 G d de4e          Z6 G d de4e          Z7 G d dee8e9e9f                            Z:dS )     )annotationsN)TYPE_CHECKING)nodes)
directives)addnodes)pending_xrefpending_xref_condition)ObjectDescription)_parse_annotation_parse_arglist_parse_type_list_pseudo_parse_arglistparse_reftarget)_)logging)FieldGroupedField
TypedField)make_id)Sequence)ClassVar)Node)Inliner)desc_signature)BuildEnvironment)
OptionSpecTextlikeNodeaI  ^ ([\w.]*\.)?            # class name(s)
          (\w+)  \s*             # thing name
          (?: \[\s*(.*?)\s*])?   # optional: type parameters list
          (?: \(\s*(.*)\s*\)     # optional: arguments
           (?:\s* -> \s* (.*))?  #           return annotation
          )? $                   # and nothing more
      c                  t     e Zd Zej        ddddfd fdZ ej        d          Zej        ddddfddZ	 xZ
S )PyXrefMixinNrolenamestrdomaintarget	innernodetype[TextlikeNode]contnodeNode | NoneenvBuildEnvironment | NoneinlinerInliner | Nonelocationreturnr   c	           
        t                                          ||||||d d           }	t          |	t                    r|J d|	d<   |j                            d          |	d<   |j                            d          |	d<   t          |          \  }
}}}||k    r.|
|	d<   ||	d<   |	                                 |	 |||          z  }	n|j        j	        r{|	j
        }|	                                 |                    d          d	         } |d
|          }t          d
d
|d          t          d
d
g|R ddig}|	                    |           |	S )N)r*   r,   Trefspecific	py:modulepy:classreftype	reftarget. resolved)	conditionr8   *)super	make_xref
isinstancer   ref_contextgetr   clearconfig!python_use_unqualified_type_nameschildrensplitr	   extend)selfr    r"   r#   r$   r&   r(   r*   r,   resultr2   r3   reftitler   rB   	shortnametextnode	contnodes	__class__s                     ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/domains/python/_object.pyr;   zPyXrefMixin.make_xref8   s    "" # 	
 	
 fl++ 	)???$(F=!"%/"5"5k"B"BF;!$!4!4Z!@!@F:.=f.E.E+GY!H$$$+y!&/{#))Hh777= 
)!?"LL--b1	$9R33*2r8zRRR*2rLHLLLLL	 i(((    z>(\s*[\[\]\(\),](?:\s*o[rf]\s)?\s*|\s+o[rf]\s+|\s*\|\s*|\.\.\.)
list[Node]c	                   | j                             |          }	t          |o|                                |k              }
d}g }t	          d |	          D ]}|
rt          j        |          }|s| j                             |          r"|                    |p |||                     n/|                    | 	                    ||||||||                     |dv rd}|S )NF>   typing.Literal~typing.LiteralLiteralT)
_delimiters_rerC   boolastextfilterr   Textmatchappendr;   )rE   r    r"   r#   r$   r&   r(   r*   r,   sub_targetssplit_contnode
in_literalresults
sub_targets                 rL   
make_xrefszPyXrefMixin.make_xrefsn   s    )//77hF8??+<+<+FGG
 {33 	" 	"J 2 :j11 T066zBB xL99Z+L+LMMMMNN "!  	 	   MMM!
rM   )r    r!   r"   r!   r#   r!   r$   r%   r&   r'   r(   r)   r*   r+   r,   r'   r-   r   )r    r!   r"   r!   r#   r!   r$   r%   r&   r'   r(   r)   r*   r+   r,   r'   r-   rN   )__name__
__module____qualname__r   emphasisr;   recompilerS   r_   __classcell__)rK   s   @rL   r   r   7   s         ). $'+"& $0 0 0 0 0 0 0d  RZI N ). $'+"& $( ( ( ( ( ( ( ( (rM   r   c                      e Zd ZdS )PyFieldNr`   ra   rb    rM   rL   rh   rh              DrM   rh   c                      e Zd ZdS )PyGroupedFieldNri   rj   rM   rL   rm   rm      rk   rM   rm   c                      e Zd ZdS )PyTypedFieldNri   rj   rM   rL   ro   ro      rk   rM   ro   c                     e Zd ZU dZej        ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        dZded<    e	d e
d          ddd	d
           e	d e
d          dddd
           ed e
d          ddd
           ed e
d          dd           ed e
d          ddd          gZdZd6d"Zd7d$Zd8d(Zd9d+Zd:d.Zd;d1Zd<d2Zd<d3Zd=d4Zd5S )>PyObjectzDescription of a general Python object.

    :cvar allow_nesting: Class is an object that allows for nested namespaces
    :vartype allow_nesting: bool
    )zno-indexno-index-entryzno-contents-entryzno-typesettingnoindexnoindexentrynocontentsentrysingle-line-parameter-listsingle-line-type-parameter-listmodule	canonical
annotationzClassVar[OptionSpec]option_spec	parameter
Parameters)paramr|   argargumentkeywordkwargkwparamclass)	paramtypetypeT)labelnamestyperolename	typenamescan_collapsevariable	Variables)varivarcvar)vartype
exceptionsRaisesexc)raisesraise	exceptionexcept)r   r    r   r   returnvalueReturnsF)returnsr-   )r   has_argr   
returntypezReturn type)rtype)r   r   r   bodyrolenamesigr!   r-   Sequence[nodes.Node]c                    g S )zTMay return a prefix to put before the object name in the
        signature.
        rj   )rE   r   s     rL   get_signature_prefixzPyObject.get_signature_prefix   s	     	rM   rT   c                    dS )zqMay return true if an empty argument list is to be generated even if
        the document contains none.
        Frj   )rE   s    rL   needs_arglistzPyObject.needs_arglist   s	     urM   signoder   tuple[str, str]c           	        t                               |          }|t          |                                \  }}}}}| j                            d| j        j                            d                    }	| j        j                            d          }
|
rfd}|rN||
k    s|                    |
 d          r0||z   }|t          |
          d         
                    d          }n7|r
|
 d| | }n+|
 d| }n#d}|r|                    d          }
||z   }nd}
|}|	|d<   |
|d	<   ||d
<   | j        j        p| j        j        pd}t          |          }|                    d          }d| j        vo!||d         |d         z
  z
  |cxk    odk    nc }|                    d          }d| j        vo!||d         |d         z
  z
  |cxk    odk    nc }| j        j        j        }|                     |          }|rNt%          |          t&          u rd| d}t)          |          |t+          j        t'          |          dg|R  z  }|r|t+          j        ||          z  }n-|	r+|r)| j        j        r|	 d}|t+          j        ||          z  }|t+          j        ||          z  }|rQ	 |t5          || j        ||          z  }n5# t6          $ r(}t8                              d|||           Y d}~nd}~ww xY w|r	 |t=          || j        ||          z  }n# t>          $ r:}t8                               d|||           tC          ||||           Y d}~n{d}~wtD          t          f$ r:}t8                              d|||           tC          ||||           Y d}~n2d}~ww xY w| #                                r|t+          j$                    z  }|r+tK          || j                  }|t+          j&        |dg|R  z  }| j                            d          }|r@|t+          j        d| dt+          j'                    tQ          j)        |                    z  }||fS )aJ  Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        Nrx   r0   r1   Fr4   Tr6   r   fullnamer      rv         rw   z^Python directive method get_signature_prefix() must return a list of nodes. Return value was 'z'.z could not parse tp_list (%r): %sr,   z syntax error in arglist (%r): %sz could not parse arglist (%r): %srz    )*	py_sig_rerX   
ValueErrorgroupsoptionsr>   r(   r=   
startswithlenlstriprstripr@   $python_maximum_signature_line_lengthmaximum_signature_line_lengthspan.python_trailing_comma_in_multi_line_signaturesr   r   r!   	TypeErrorr   desc_annotationdesc_addnameadd_module_names	desc_namer   	Exceptionloggerwarningr   SyntaxErrordebugr   NotImplementedErrorr   desc_parameterlistr   desc_returnsdesc_sig_spacer   rW   )rE   r   r   mprefixnametp_listarglistretannmodname	classname
add_moduler   max_lensig_lentp_list_spanmulti_line_parameter_listarglist_spanmulti_line_type_parameter_listtrailing_comma
sig_prefixmsgnodetextr   rB   annos                             rL   handle_signaturezPyObject.handle_signature   s    OOC  912.gw ,""8TX-A-E-Ek-R-RSSH(,,Z88	 	 J 
16Y..&2C2CyOOO2T2T.!D=I 0 0188== 1 (88&8$88 (00$00J  "MM#..	!D=	#$&
 K< {8 	 c((vvayy(< NLOl1o=>'MMMMAMMMM 	" vvayy-T\A NLOl1o=>'MMMMAMMMM 	'
 W..s33
 	RJ3&&9*49 9 9 
  nn$x/JQjQQQQG 	Ax,VV<<<GG 	A 	A(D 	A!}}}Hx,Xx@@@G8%dD111 	
+H2"	      6w         
  $	9>H-"	      
 6w     &-"	        (4 
 
 
6w     &-"	       
 !!## 986888 	D(::Hx,VRC(CCCCG|-- 	x/D

B 7 9 95:d;K;K  G s<   1K 
K>K99K>L 
N,)0MN,20N''N,sig_nodetuple[str, ...]c                    d|vrdS |                     d          }|d         }|r|g|                    d          R S t          |                    d                    S )Nr   rj   rx   r4   )r>   rC   tuple)rE   r   r   r   s       rL   _object_hierarchy_partsz PyObject._object_hierarchy_parts  sl    X%%2,,x((J' 	.2hnnS11222,,---rM   r   r   c                $    d}t          |          )z2Return the text for the index entry of the object.z!must be implemented in subclasses)r   )rE   r   r   r   s       rL   get_index_textzPyObject.get_index_text  s    1!#&&&rM   name_clsNonec                   | j                             d| j        j                            d                    }|r| dnd|d         z   }t	          | j        | j        j        d|          }|d                             |           | j        j                            |           | j        j	        j
        }|                    || j        ||           | j                             d          }|r|                    || j        |d	|
           d| j         vr?|                     ||          x}	r)| j        d                             d|	|dd f           d S d S d S )Nrx   r0   r4   r6   r   idsr   ry   T)aliasedr,   rr   entriessingle)r   r>   r(   r=   r   statedocumentrY   note_explicit_targetdomainspython_domainnote_objectobjtyper   	indexnode)
rE   r   r   r   mod_namer   node_idr"   canonical_name
index_texts
             rL   add_target_and_indexzPyObject.add_target_and_index  s    <##Hdh.B.F.F{.S.STT&.6xNNNNB(1+E$(DJ$7XFFg&&&
00999!/8T\7WMMM))+66 	gtg     4<//!008DDDz y)002      0/ rM   c                   d}| j         r1| j         d         \  }}| j        r|}n|r|                    d          }|rK|| j        j        d<   | j        r5| j        j                            dg           }|                    |           d| j        v rn| j        j                            dg           }|                    | j        j                            d                     | j        d         | j        j        d<   dS dS )	a  Handle object nesting before content

        :py:class:`PyObject` represents Python language constructs. For
        constructs that are nestable, such as a Python classes, this method will
        build up a stack of the nesting hierarchy so that it can be later
        de-nested correctly, in :py:meth:`after_content`.

        For constructs that aren't nestable, the stack is bypassed, and instead
        only the most recent object is tracked. This object prefix name will be
        removed with :py:meth:`after_content`.
        Nr5   r4   r1   
py:classesrx   
py:modulesr0   )	r   allow_nestingstripr(   r=   
setdefaultrY   r   r>   )rE   r   r   name_prefixclassesmoduless         rL   before_contentzPyObject.before_content  s    : 		0
 '+jn#X{! 0! 0$**3// 	'/5DH ,! '(.99,KKv&&&t|##h*55lBGGGNN48/33K@@AAA04X0FDH --- $#rM   c                   | j         j                            dg           }| j        rEt	          j        t                    5  |                                 ddd           n# 1 swxY w Y   t          |          dk    r|d         nd| j         j        d<   d| j	        v rf| j         j                            dg           }|r#|                                | j         j        d<   dS | j         j                            d           dS dS )	a^  Handle object de-nesting after content

        If this class is a nestable object, removing the last nested class prefix
        ends further nesting in the object.

        If this class is not a nestable object, the list of classes should not
        be altered as we didn't affect the nesting levels in
        :py:meth:`before_content`.
        r   Nr   r5   r1   rx   r   r0   )
r(   r=   r   r   
contextlibsuppress
IndexErrorpopr   r   )rE   r   r  s      rL   after_contentzPyObject.after_content  s9    (&11,CC 	$Z00                 ;>g,,:J:J72;;PTZ(t|##h*55lBGGG 64;KKMM$[111$((55555 $#s   A""A&)A&c                b   |                     d          sdS | j        }|j                             d          }|j        r|dv rd}nd}|d         ^ }}|j        dk    r|                     d|          |z   S |j        dk    r||z   S |j        d	k    rd
                    g |||z             S dS )N
_toc_partsr6   r   >   methodfunctionz()r"   r   hideallr4   )r>   r@   parentadd_function_parenthesestoc_object_entries_show_parentsjoin)rE   r   r@   r   parensparentsr   s          rL   _toc_entry_namezPyObject._toc_entry_name  s    ||L)) 	2/%%i00* 	w:P/P/PFFF!,/$1X==<<
D11F::1V;;&= 1U::885g5tf}5666rrM   N)r   r!   r-   r   )r-   rT   )r   r!   r   r   r-   r   )r   r   r-   r   )r   r!   r   r   r-   r!   )r   r   r   r!   r   r   r-   r   )r-   r   )r   r   r-   r!   )r`   ra   rb   __doc__r   flag	unchangedr{   __annotations__ro   r   rm   r   rh   doc_field_typesr   r   r   r   r   r   r   r  r  r  rj   rM   rL   rq   rq      s9          O$/'_$/?"%?&0o+5?&) *) )K      	!L// !+	
 	
 	
  	!K..) "	
 	
 	
 	!H++<	
 	
 	
 	!I,,'		
 	
 	
 	!M"" 	
 	
 	
M-O^ M      S  S  S  S j	. 	. 	. 	.' ' ' '
   8G G G GB6 6 6 6.     rM   rq   );
__future__r   r  rd   typingr   docutilsr   docutils.parsers.rstr   sphinxr   sphinx.addnodesr   r	   sphinx.directivesr
   "sphinx.domains.python._annotationsr   r   r   r   r   sphinx.localer   sphinx.utilr   sphinx.util.docfieldsr   r   r   sphinx.util.nodesr   collections.abcr   r   docutils.nodesr   docutils.parsers.rst.statesr   r   sphinx.environmentr   sphinx.util.typingr   r   	getLoggerr`   r   re   VERBOSEr   r   rh   rm   ro   r   r!   rq   rj   rM   rL   <module>r.     s   " " " " " "     				                   + + + + + +       @ @ @ @ @ @ @ @ / / / / / /                          A A A A A A A A A A       	<((((((######333333......333333;;;;;;;;		8	$	$ BJ
 J	 		_ _ _ _ _ _ _ _D	 	 	 	 	k5 	 	 		 	 	 	 	[, 	 	 		 	 	 	 	;
 	 	 	] ] ] ] ] sCx1 ] ] ] ] ]rM   