
    -Ph/                       d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 erJddl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 ddlmZ ddlm Z  ddl!m"Z"m#Z# dZ$ G d d          Z% G d d          Z&dS )zSupport for domains.

Domains are groupings of description directives
and roles describing e.g. constructs of one programming language.
    )annotationsN)TYPE_CHECKING)Index
IndexEntry)_)IterableSequenceSet)Any)nodes)ElementNode)	Directive)Inliner)pending_xref)Builder)BuildEnvironment)XRefRole)RoleFunctionTitleGetter)Domainr   r   ObjTypec                  "    e Zd ZdZddiZddZdS )r   a.  An ObjType is the description for a type of object that a domain can
    document.  In the object_types attribute of Domain subclasses, object type
    names are mapped to instances of this class.

    Constructor arguments:

    - *lname*: localized name of the type (do not include domain name)
    - *roles*: all the roles that can refer to an object of this type
    - *attrs*: object attributes -- currently only "searchprio" is known,
      which defines the object's priority in the full-text search index,
      see :meth:`Domain.get_objects()`.
    
searchprio   lnamestrrolesr   attrsreturnNonec               @    || _         || _        | j        |z  | _        d S N)r   r   known_attrsr   )selfr   r   r   s       W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/domains/__init__.py__init__zObjType.__init__8   s#    
&+
%)%5%=


    N)r   r   r   r   r   r   r    r!   )__name__
__module____qualname____doc__r$   r'    r(   r&   r   r   &   s@          	aK> > > > > >r(   r   c                     e Zd ZU dZdZdZi Zded<   i Zded<   i Z	ded<   g Z
d	ed
<   i Zded<   i Zded<   i Zded<   ded<   dZdGdZdHdZdIdZdJdZdKd!ZdLd#ZdMd'ZdNd*ZdHd+ZdOd.ZdPd8ZdQd:ZdRd<ZdSdTdAZdUdDZdVdEZdFS )Wr   a  A Domain is meant to be a group of "object" description directives for
    objects of a similar nature, and corresponding roles to create references to
    them.  Examples would be Python modules, classes, functions etc., elements
    of a templating language, Sphinx roles and directives, etc.

    Each domain has a separate storage for information about existing objects
    and how to reference them in `self.data`, which must be a dictionary.  It
    also must implement several functions that expose the object information in
    a uniform way to parts of Sphinx that allow the user to reference or search
    for objects in a domain-agnostic way.

    About `self.data`: since all object and cross-referencing information is
    stored on a BuildEnvironment instance, the `domain.data` object is also
    stored in the `env.domaindata` dict under the key `domain.name`.  Before the
    build process starts, every active domain is instantiated and given the
    environment object; the `domaindata` dict must then either be nonexistent or
    a dictionary whose 'version' key is equal to the domain class'
    :attr:`data_version` attribute.  Otherwise, `OSError` is raised and the
    pickled environment is discarded.
     zdict[str, ObjType]object_typeszdict[str, type[Directive]]
directivesz"dict[str, RoleFunction | XRefRole]r   zlist[type[Index]]indiceszdict[str, str]dangling_warningsz0dict[type[Node], tuple[str, TitleGetter | None]]enumerable_nodesdict[str, Any]initial_datadatar   envr   r    r!   c                   |j         }|| _        i | _        i | _        i | _        i | _        t          | j                  | _        t          | j                  | _        t          | j	                  | _	        t          | j                  | _        | j        |vrQt          | j        t                    sJ t          j        | j                  }| j        |d<   |x| _        || j        <   n?|| j                 | _        | j        d         | j        k    rt'          d| j        z            | j                                        D ][\  }}|j	        D ]0}| j                            |g                               |           1|j	        r|j	        d         nd| j        |<   \| j        j        | _        | j        j        | _        d S )Nversionzdata of %r domain out of dater   r/   )
domaindatar8   _role_cache_directive_cache
_role2type
_type2roledictr0   r1   r   listr2   name
isinstancer6   copydeepcopydata_versionr7   OSErrorlabelitems
setdefaultappendgetobjtypes_for_rolerole_for_objtype)r%   r8   domain_datanew_datarB   objrolenames          r&   r'   zDomain.__init__k   s   14%(46<>02*, !!233t//$*%%
DL))9K''d/66666}T%677H"&"3HY199DIDI..#DI.DIy#t'888=
JKKK*0022 	F 	FID#I F F**8R88??EEEE47I$ECIaLL2DOD!!!%!4 $ 3r(   c                    | j         j        j        }| j        D ]>}|j        r5|j        r.| j         d|j         }|                    ||d|j                   ?dS )zSet up domain object.-r/   N)r8   domainsstandard_domainr2   rB   	localnamenote_hyperlink_target)r%   stdindexdocnames       r&   setupzDomain.setup   sy     h.\ 	Q 	QEz Qeo Q!Y5555))'7BPPP	Q 	Qr(   rB   r   objtyper   c                    || j         |<   |j        r|j        d         | j        |<   n
d| j        |<   |j        D ]0}| j                            |g                               |           1dS )zAdd an object type.r   r/   N)r0   r   r?   r>   rJ   rK   )r%   rB   r]   roles       r&   add_object_typezDomain.add_object_type   s    ")$= 	'$+M!$4DOD!!$&DOD!M 	> 	>DO&&tR0077====	> 	>r(   RoleFunction | Nonec                      j         v r j                  S  j        vrdS  j         d 	 	 dd fd}| j         <   |S )zReturn a role adapter function that always gives the registered
        role its full name ('domain:name') as the first argument.
        N:r-   typr   rawtexttextlinenointinlinerr   optionsdict[str, Any] | NonecontentSequence[str]r    -tuple[list[Node], list[nodes.system_message]]c           	     @     	j                  |||||pi |          S r#   )r   )
rd   re   rf   rg   ri   rj   rl   fullnamerB   r%   s
          r&   role_adapterz!Domain.role.<locals>.role_adapter   s3     $4:d#'4'-R  r(   )Nr-   )rd   r   re   r   rf   r   rg   rh   ri   r   rj   rk   rl   rm   r    rn   )r<   r   rB   )r%   rB   rq   rp   s   `` @r&   r_   zDomain.role   s     4####D))tz!!4i(($(( .2%'	 	 	 	 	 	 	 	 	 ".r(   type[Directive] | Nonec                    || j         v r| j         |         S || j        vrdS | j         d| | j        |         } G fdd|          }|| j         |<   |S )zReturn a directive adapter class that always gives the registered
        directive its full name ('domain:name') as ``self.name``.
        Nrc   c                  $     e Zd Zd fdZ xZS )*Domain.directive.<locals>.DirectiveAdapterr    
list[Node]c                R    | _         t                                                      S r#   )rB   superrun)r%   	__class__rp   s    r&   ry   z.Domain.directive.<locals>.DirectiveAdapter.run   s    $	ww{{}}$r(   )r    rv   )r)   r*   r+   ry   __classcell__)rz   rp   s   @r&   DirectiveAdapterru      sC        % % % % % % % % % % %r(   r|   )r=   r1   rB   )r%   rB   BaseDirectiver|   rp   s       @r&   	directivezDomain.directive   s     4((((..t&&4i(($((-	% 	% 	% 	% 	% 	% 	%} 	% 	% 	%
 '7d#r(   r[   c                    dS )z?Remove traces of a document in the domain-specific inventories.Nr-   )r%   r[   s     r&   	clear_doczDomain.clear_doc       r(   docnamesSet[str]	otherdatac                6    d| j          d}t          |          )zMerge in data regarding *docnames* from a different domaindata
        inventory (coming from a subprocess in parallel builds).
        z(merge_domaindata must be implemented in z" to be able to do parallel builds!)rz   NotImplementedError)r%   r   r   msgs       r&   merge_domaindatazDomain.merge_domaindata   s/    
0t~ 0 0 0 	 "#&&&r(   documentnodes.documentc                    dS )z7Process a document after it is read by the environment.Nr-   )r%   r8   r[   r   s       r&   process_doczDomain.process_doc   	     	r(   c                    dS )z)Do consistency checks (**experimental**).Nr-   r%   s    r&   check_consistencyzDomain.check_consistency   r   r(   pnoder   c                    dS )zxProcess a pending xref created in a doc field.
        For example, attach information about the current scope.
        Nr-   )r%   r   s     r&   process_field_xrefzDomain.process_field_xref   r   r(   fromdocnamebuilderr   rd   targetnodecontnoder   nodes.reference | Nonec                    dS )aL  Resolve the pending_xref *node* with the given *typ* and *target*.

        This method should return a new node, to replace the xref node,
        containing the *contnode* which is the markup content of the
        cross-reference.

        If no resolution can be found, None can be returned; the xref node will
        then given to the :event:`missing-reference` event, and if that yields no
        resolution, replaced by *contnode*.

        The method can also raise :exc:`sphinx.environment.NoUri` to suppress
        the :event:`missing-reference` event being emitted.
        Nr-   )r%   r8   r   r   rd   r   r   r   s           r&   resolve_xrefzDomain.resolve_xref   s	    . 	r(   !list[tuple[str, nodes.reference]]c                    t           )a9  Resolve the pending_xref *node* with the given *target*.

        The reference comes from an "any" or similar role, which means that we
        don't know the type.  Otherwise, the arguments are the same as for
        :meth:`resolve_xref`.

        The method must return a list (potentially empty) of tuples
        ``('domain:role', newnode)``, where ``'domain:role'`` is the name of a
        role that could have created the same reference, e.g. ``'py:func'``.
        ``newnode`` is what :meth:`resolve_xref` would return.

        .. versionadded:: 1.3
        )r   )r%   r8   r   r   r   r   r   s          r&   resolve_any_xrefzDomain.resolve_any_xref  s
    , "!r(   -Iterable[tuple[str, str, str, str, str, int]]c                    g S )au  Return an iterable of "object descriptions".

        Object descriptions are tuples with six items:

        ``name``
          Fully qualified name.

        ``dispname``
          Name to display when searching/linking.

        ``type``
          Object type, a key in ``self.object_types``.

        ``docname``
          The document where it is to be found.

        ``anchor``
          The anchor name for the object.

        ``priority``
          How "important" the object is (determines placement in search
          results). One of:

          ``1``
            Default priority (placed before full-text matches).
          ``0``
            Object is important (placed before default-priority objects).
          ``2``
            Object is unimportant (placed after full-text matches).
          ``-1``
            Object should not show up in search at all.
        r-   r   s    r&   get_objectszDomain.get_objects  s
    B 	r(   Ftypeprimaryboolc                P    |r|j         S t          d          | j        |j         fz  S )z#Return full name for given ObjType.z%s %s)r   r   rH   )r%   r   r   s      r&   get_type_namezDomain.get_type_name>  s,     	:zzTZ444r(   r   
str | Nonec                L    | j                             |j        d          \  }}|S )z,Get type of enumerable nodes (experimental).)NN)r4   rL   rz   )r%   r   enum_node_typer   s       r&   get_enumerable_node_typezDomain.get_enumerable_node_typeD  s'     155dnlSSr(   c                    dS )z*Return full qualified name for given node.Nr-   )r%   r   s     r&   get_full_qualified_namezDomain.get_full_qualified_nameI  r   r(   N)r8   r   r    r!   )r    r!   )rB   r   r]   r   r    r!   )rB   r   r    ra   )rB   r   r    rr   )r[   r   r    r!   )r   r   r   r5   r    r!   )r8   r   r[   r   r   r   r    r!   )r   r   r    r!   )r8   r   r   r   r   r   rd   r   r   r   r   r   r   r   r    r   )r8   r   r   r   r   r   r   r   r   r   r   r   r    r   )r    r   )F)r   r   r   r   r    r   )r   r   r    r   )r   r   r    r   )r)   r*   r+   r,   rB   rH   r0   __annotations__r1   r   r2   r3   r4   r6   rF   r'   r\   r`   r_   r~   r   r   r   r   r   r   r   r   r   r   r   r-   r(   r&   r   r   >   s          , DE')L))))-/J////02E2222!#G####(*****IKKKKK#%L%%%%L4 4 4 4<Q Q Q Q	> 	> 	> 	>   4       *   ' ' ' '            2" " " "0! ! ! !F5 5 5 5 5   
     r(   r   )'r,   
__future__r   rD   typingr   sphinx.domains._indexr   r   sphinx.localer   collections.abcr   r	   r
   r   docutilsr   docutils.nodesr   r   docutils.parsers.rstr   docutils.parsers.rst.statesr   sphinx.addnodesr   sphinx.buildersr   sphinx.environmentr   sphinx.rolesr   sphinx.util.typingr   r   __all__r   r   r-   r(   r&   <module>r      s    # " " " " "              3 3 3 3 3 3 3 3       =7777777777,,,,,,,,......333333,,,,,,''''''333333%%%%%%<<<<<<<<> > > > > > > >0M M M M M M M M M Mr(   