
    }c'                        d Z ddlZddlmZmZmZ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 ddl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 ddlmZ erddlm Z   ej!        d          Z" ej!        d          Z# e	d          Z$de%de&fdZ' G d deee$                   Z( G d de          Z) G d de          Z*dddee%ef         fdZ+dS )z(Handlers for additional ReST directives.    N)TYPE_CHECKINGAnyDictGenericListTupleTypeVarcast)nodes)Node)
directivesroles)addnodes)desc_signature)docutils)DocFieldTransformerField
TypedField)SphinxDirective)
OptionSpec)Sphinxz\\\nz\\(.)Targumentreturnc                 V    | dS t          |           }|dk     rt          d          |S )zS
    Check for an integer argument or None value; raise ``ValueError`` if not.
    Nr   z(negative value; must be positive or zero)int
ValueError)r   values     :lib/python3.11/site-packages/sphinx/directives/__init__.pyoptional_intr       s=      tH19 	IGHHH    c                   n   e Zd ZU dZdZdZdZdZdej	        iZ
eed<   g Zee         ed<   dZeed	<   dZeed
<   dZej        ed<   i Zeeeeef         f         ed<   deeeeef         f         fdZdee         fdZdededefdZdedededdfdZddZ dej!        ddfdZ"ddZ#dee$         fdZ%dS )ObjectDescriptionz
    Directive to describe a class, function or similar object.  Not used
    directly, but subclassed (in domain-specific directives) to add custom
    behavior.
    T   r   noindexoption_specdoc_field_typesNdomainobjtype	indexnode_doc_field_type_mapr   c                     | j         i k    rYi | _         | j        D ]J}|j        D ]}|df| j         |<   |j        r+t	          t
          |          }|j        D ]}|df| j         |<   K| j         S )NFT)r+   r'   namesis_typedr
   r   	typenames)selffieldnametyped_fields       r   get_field_type_mapz$ObjectDescription.get_field_type_mapA   s    #r) 		G')D$- G G!K D DD6;U^D,T22> G"&z5"9"9K + 5 G G:?066''r!   c                     t                               d| j        d                                       d          }| j        j        rd |D             S d |D             S )z
        Retrieve the signatures to document from the directive arguments.  By
        default, signatures are given as arguments, one per line.
         r   
c                 h    g | ]/}t                               d |                                          0S )z\1)strip_backslash_resubstrip.0lines     r   
<listcomp>z4ObjectDescription.get_signatures.<locals>.<listcomp>W   s1    RRRD&**5$**,,??RRRr!   c                 6    g | ]}|                                 S  )r;   r<   s     r   r?   z4ObjectDescription.get_signatures.<locals>.<listcomp>Y   s     333TDJJLL333r!   )nl_escape_rer:   	argumentssplitconfigstrip_signature_backslash)r0   liness     r   get_signaturesz ObjectDescription.get_signaturesO   sc    
   T^A%677==dCC;0 	4RRERRRR33U3333r!   sigsignodec                     t           )a  
        Parse the signature *sig* into individual nodes and append them to
        *signode*. If ValueError is raised, parsing is aborted and the whole
        *sig* is put into a single desc_name node.

        The return value should be a value that identifies the object.  It is
        passed to :meth:`add_target_and_index()` unchanged, and otherwise only
        used to skip duplicates.
        )r   )r0   rI   rJ   s      r   handle_signaturez"ObjectDescription.handle_signature[   s
     r!   r2   c                     dS )z
        Add cross-reference IDs and entries to self.indexnode, if applicable.

        *name* is whatever :meth:`handle_signature()` returned.
        NrA   )r0   r2   rI   rJ   s       r   add_target_and_indexz&ObjectDescription.add_target_and_indexg   s	     	r!   c                     dS )z
        Called before parsing content. Used to set information about the current
        directive context on the build environment.
        NrA   r0   s    r   before_contentz ObjectDescription.before_contento   	    
 	r!   contentnodec                     dS )z
        Called after creating the content through nested parsing,
        but before the ``object-description-transform`` event is emitted,
        and before the info-fields are transformed.
        Can be used to manipulate the content.
        NrA   )r0   rS   s     r   transform_contentz#ObjectDescription.transform_contentv   s	     	r!   c                     dS )z
        Called after parsing content. Used to reset information about the
        current directive context on the build environment.
        NrA   rP   s    r   after_contentzObjectDescription.after_content   rR   r!   c                    d| j         v r)| j                             dd          \  | _        | _        nd| j         c| _        | _        t	          j        g           | _        t	          j                    }| j        j	        |_	        | j        |d<   | j        x|d<   |d<   d| j
        v x|d<   }| j        r |d	                             | j                   |d	                             |d                    g | _        |                                 }|D ]}t	          j        |d          }|                     |           |                    |           	 |                     ||          }n<# t"          $ r/ |                                 |t	          j        ||          z  }Y w xY w|| j        vr3| j                            |           |s|                     |||           t	          j                    }|                    |           | j        r| j        d
         | j        j        d<   |                                  | j                            | j        | j        |           |                     |           | j        j                            d| j        | j        |           t?          |                                |           d| j        j        d<   | !                                 | j        |gS )a  
        Main directive entry function, called by docutils upon encountering the
        directive.

        This directive is meant to be quite easily subclassable, so it delegates
        to several additional methods.  What it does:

        * find out if called as a domain-specific directive, set self.domain
        * create a `desc` node to fit all description inside
        * parse standard options, currently `noindex`
        * create an index node if needed as self.indexnode
        * parse all given signatures (as returned by self.get_signatures())
          using self.handle_signature(), which should either return a name
          or raise ValueError
        * add index entries using self.add_target_and_index()
        * parse the content and handle doc fields in it
        :r$   r6   )entriesr(   r)   desctyper%   classesr   objectobject-description-transformN)"r2   rD   r(   r)   r   indexr*   descstatedocumentoptionsappendr-   rH   r   set_source_inforL   r   clear	desc_namerN   desc_contentenv	temp_datarQ   nested_parsecontentcontent_offsetrU   appemitr   transform_allrW   )r0   noder%   
signaturesrI   rJ   r2   rS   s           r   runzObjectDescription.run   s   $ $) 	6(,	Q(?(?%DK(*DI%DK!333}
+X-1\9Y$z*%.$,%>?Y'; 	0O""4;///YtI/// 
((**
 	B 	BC -c266G  )))KK   	 ,,S'::   8-c3777	
 4:% B
!!$''' B --dCAAA+--K   : 	9+/:a=DHx(
d.A;OOO{+++8+t|[	B 	B 	BD!!//<<<'+8$%%s   E**6F#"F#)r   N)&__name__
__module____qualname____doc__has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   flagr&   r   __annotations__r'   r   r   r(   strr)   r*   r   r_   r+   r   r   boolr4   rH   r   r   rL   rN   rQ   rh   rU   rW   r   rs   rA   r!   r   r#   r#   )   s          K $:?K   
 $&OT%[%%%FCGS $Ix~$$$ :<c5#556;;;(DeE4K.@)@$A ( ( ( (
4S	 
4 
4 
4 
4
C 
. 
Q 
 
 
 
  ~ RV       X-B t       H&T$Z H& H& H& H& H& H&r!   r#   c                   2    e Zd ZdZdZdZdee         fdZdS )DefaultRolezK
    Set the default interpreted text role.  Overridden from docutils.
    r$   Fr   c                    | j         st          j        d           g S | j         d         }t          j        || j        j        | j        | j        j	                  \  }}|r%t          j
        d|           || j        j        d<   nQt          j        | j        | j                  }| j        j	        }|                    d|z  || j                  }||gz  }t#          t$          t          j                 |          S )Nr6   r   default_rolez#Unknown interpreted text role "%s".)r>   )rC   r   unregister_roler   rolestate_machinelanguagelinenora   reporterregister_roleri   rj   r   literal_block
block_texterrorr
   r   r   )r0   	role_namer   messagesr   r   r   s          r   rs   zDefaultRole.run   s    ~ 	$R(((IN1%	It/A/J$(K1DF Fh 	 "2t,,,1:DH~..!/QQMz*HNN#H9#T#0t{ # D DEHD$h///r!   N)	rt   ru   rv   rw   rz   r{   r   r   rs   rA   r!   r   r   r      sK           %0T$Z 0 0 0 0 0 0r!   r   c                   J    e Zd ZU dZdZdZdZdZi Ze	e
d<   dee         fdZdS )	DefaultDomainzH
    Directive to (re-)set the default domain for this source file.
    Fr$   r   r&   r   c                     | j         d                                         }| j        j                            |          | j        j        d<   g S )Nr   default_domain)rC   lowerri   domainsgetrj   )r0   domain_names     r   rs   zDefaultDomain.run   sD    nQ'--// 04x/?/C/CK/P/P+,	r!   N)rt   ru   rv   rw   rx   ry   rz   r{   r&   r   r}   r   r   rs   rA   r!   r   r   r      sh           K % K   	T$Z 	 	 	 	 	 	r!   r   rn   r   c                 6   |                      ddd           t          j        dt                     t          j        dt                     t          j        dt
                     t          j        dt
                     |                     d           d	d
d
dS )NrF   Fri   zdefault-rolezdefault-domaindescriber]   r^   builtinT)versionparallel_read_safeparallel_write_safe)add_config_valuer   register_directiver   r   r#   	add_event)rn   s    r   setupr     s    4eUCCC!.+>>>!"2MBBB!*.?@@@!(,=>>>MM0111 "#  r!   ),rw   retypingr   r   r   r   r   r   r	   r
   r   r   docutils.nodesr   docutils.parsers.rstr   r   sphinxr   sphinx.addnodesr   sphinx.utilsphinx.util.docfieldsr   r   r   sphinx.util.docutilsr   sphinx.util.typingr   sphinx.applicationr   compilerB   r9   r   r~   r   r    r#   r   r   r   rA   r!   r   <module>r      s3   . . 				 P P P P P P P P P P P P P P P P P P P P             2 2 2 2 2 2 2 2       * * * * * *             H H H H H H H H H H 0 0 0 0 0 0 ) ) ) ) ) ) *)))))) rz'""RZ)) GCLL
3 
3 
 
 
 
e& e& e& e& e& e& e& e&P0 0 0 0 0/ 0 0 08    O   .x DcN      r!   