
    zi<                    |   d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
mZmZmZ ddlmZmZmZ ddlmZ ddlmZ er8d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& ddl'm(Z(  G d d          Z) G d de          Z* G d de          Z+e
egee,         f         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)ABCabstractmethod)TYPE_CHECKINGAnyCallable
NamedTupleOptionalcast)ElementNodesystem_message)SphinxError)_)IterableSequence)nodes)	Directive)Inliner)pending_xref)Builder)BuildEnvironment)XRefRole)RoleFunctionc                  "    e Zd ZdZddiZddZdS )ObjTypea3  
    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                                        | _        | j                            |           d S N)r   r!   known_attrscopyr"   update)selfr   r!   r"   s       b/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/sphinx/domains/__init__.py__init__zObjType.__init__3   sB    
!
+0022

%         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                  V    e Zd ZU ded<   ded<   ded<   ded<   ded<   ded<   ded	<   d
S )
IndexEntryr    nameintsubtypedocnameanchorextra	qualifierdescrN)r.   r/   r0   __annotations__r2   r-   r+   r4   r4   :   sO         IIILLLLLLKKKJJJNNNJJJJJr-   r4   c                  X    e Zd ZU dZded<   ded<   dZded<   ddZeddd            ZdS )Indexa  
    An Index is the description for a domain-specific index.  To add an index to
    a domain, subclass Index, overriding the three name attributes:

    * `name` is an identifier used for generating file names.
      It is also used for a hyperlink target for the index. Therefore, users can
      refer the index page using ``ref`` role and a string which is combined
      domain name and ``name`` attribute (ex. ``:ref:`py-modindex```).
    * `localname` is the section title for the index.
    * `shortname` is a short name for the index, for use in the relation bar in
      HTML output.  Can be empty to disable entries in the relation bar.

    and providing a :meth:`generate()` method.  Then, add the index class to
    your domain's `indices` list.  Extensions can add indices to existing
    domains using :meth:`~sphinx.application.Sphinx.add_index_to_domain()`.

    .. versionchanged:: 3.0

       Index pages can be referred by domain name and index name via
       :rst:role:`ref` role.
    r    r5   	localnameN
str | None	shortnamedomainDomainr#   r$   c                h    | j         | j        t          d| j        j        z            || _        d S )Nz0Index subclass %s has no valid name or localname)r5   r@   r   	__class__r.   rC   )r*   rC   s     r+   r,   zIndex.__init___   s>    9 6P $ 78 9 9 9r-   docnamesIterable[str] | None/tuple[list[tuple[str, list[IndexEntry]]], bool]c                    t           )a  Get entries for the index.

        If ``docnames`` is given, restrict to entries referring to these
        docnames.

        The return value is a tuple of ``(content, collapse)``:

        ``collapse``
          A boolean that determines if sub-entries should start collapsed (for
          output formats that support collapsing sub-entries).

        ``content``:
          A sequence of ``(letter, entries)`` tuples, where ``letter`` is the
          "heading" for the given ``entries``, usually the starting letter, and
          ``entries`` is a sequence of single entries. Each entry is a sequence
          ``[name, subtype, docname, anchor, extra, qualifier, descr]``. The
          items in this sequence have the following meaning:

          ``name``
            The name of the index entry to be displayed.

          ``subtype``
            The sub-entry related type. One of:

            ``0``
              A normal entry.
            ``1``
              An entry with sub-entries.
            ``2``
              A sub-entry.

          ``docname``
            *docname* where the entry is located.

          ``anchor``
            Anchor for the entry within ``docname``

          ``extra``
            Extra info for the entry.

          ``qualifier``
            Qualifier for the description.

          ``descr``
            Description for the entry.

        Qualifier and description are not rendered for some output formats such
        as LaTeX.
        NotImplementedError)r*   rG   s     r+   generatezIndex.generatee   s    h "!r-   )rC   rD   r#   r$   r&   )rG   rH   r#   rI   )	r.   r/   r0   r1   r=   rB   r,   r   rM   r2   r-   r+   r?   r?   D   s~          , IIINNN I        3" 3" 3" 3" ^3" 3" 3"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 )WrD   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initial_datadatar   envr   r#   r$   c                   || _         i | _        i | _        i | _        i | _        t          | j                  | _        t          | j                  | _        t          | j                  | _        t          | j
                  | _
        | j        |j        vrVt          | j        t
                    sJ t          j        | j                  }| j        |d<   |x| _        |j        | j        <   nD|j        | 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   rO   )rX   _role_cache_directive_cache
_role2type
_type2rolerU   rP   rQ   r!   listrR   r5   
domaindata
isinstancerV   r(   deepcopydata_versionrW   OSErrorlabelitems
setdefaultappendgetobjtypes_for_rolerole_for_objtype)r*   rX   new_datar5   objrolenames         r+   r,   zDomain.__init__   s   %(025702*, !!233t//$*%%
DL))9CN**d/66666}T%677H"&"3HY4<<DIty11ty1DI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                    ddl m} t          || j                            d                    }| j        D ]>}|j        r5|j        r.| j         d|j         }|                    ||d|j                   ?dS )zSet up domain object.r   )StandardDomainstd-rO   N)	sphinx.domains.stdrp   r   rX   
get_domainrR   r5   r@   note_hyperlink_target)r*   rp   rq   indexr8   s        r+   setupzDomain.setup   s    555555 >48#6#6u#=#=>>\ 	Q 	QEz Qeo Q!Y5555))'7BPPP	Q 	Qr-   r5   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   rO   N)rP   r!   r^   r]   rg   rh   )r*   r5   rx   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:r2   typr    rawtexttextlinenor6   inlinerr   optionsdict | NonecontentSequence[str]r#   'tuple[list[Node], list[system_message]]c           	     @     	j                  |||||pi |          S r&   )r!   )
r   r   r   r   r   r   r   fullnamer5   r*   s
          r+   role_adapterz!Domain.role.<locals>.role_adapter
  s6     $4:d#HgtV$+W]GE E Er-   )Nr2   )r   r    r   r    r   r    r   r6   r   r   r   r   r   r   r#   r   )r[   r!   r5   )r*   r5   r   r   s   `` @r+   rz   zDomain.role   s     4####D))tz!!4i(($(( CG24	E 	E 	E 	E 	E 	E 	E 	E 	E ".r-   Callable | 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``.
        Nr~   c                  $     e Zd Zd fdZ xZS )*Domain.directive.<locals>.DirectiveAdapterr#   
list[Node]c                R    | _         t                                                      S r&   )r5   superrun)r*   rF   r   s    r+   r   z.Domain.directive.<locals>.DirectiveAdapter.run  s    $	ww{{}}$r-   )r#   r   )r.   r/   r0   r   __classcell__)rF   r   s   @r+   DirectiveAdapterr     sC        % % % % % % % % % % %r-   r   )r\   rQ   r5   )r*   r5   BaseDirectiver   r   s       @r+   	directivezDomain.directive  s     4((((..t&&4i(($((-	% 	% 	% 	% 	% 	% 	%} 	% 	% 	% '7d#r-   r8   c                    dS )z?Remove traces of a document in the domain-specific inventories.Nr2   )r*   r8   s     r+   	clear_doczDomain.clear_doc'      r-   rG   	list[str]	otherdatac                0    t          d| j        z            )zMerge in data regarding *docnames* from a different domaindata
        inventory (coming from a subprocess in parallel builds).
        zLmerge_domaindata must be implemented in %s to be able to do parallel builds!)rL   rF   )r*   rG   r   s      r+   merge_domaindatazDomain.merge_domaindata+  s&     " #F"&.#1 2 2 	2r-   documentnodes.documentc                    dS )z7Process a document after it is read by the environment.Nr2   )r*   rX   r8   r   s       r+   process_doczDomain.process_doc3  s	     	r-   c                    dS )z)Do consistency checks (**experimental**).Nr2   r*   s    r+   check_consistencyzDomain.check_consistency8  r   r-   pnoder   c                    dS )zxProcess a pending xref created in a doc field.
        For example, attach information about the current scope.
        Nr2   )r*   r   s     r+   process_field_xrefzDomain.process_field_xref<  s	     	r-   fromdocnamebuilderr   r   targetnodecontnoder   Element | 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.
        Nr2   )r*   rX   r   r   r   r   r   r   s           r+   resolve_xrefzDomain.resolve_xrefB  s	      	r-   list[tuple[str, Element]]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
        rK   )r*   rX   r   r   r   r   r   s          r+   resolve_any_xrefzDomain.resolve_any_xrefT  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.
        r2   r   s    r+   get_objectszDomain.get_objectsf  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   re   )r*   r   r   s      r+   get_type_namezDomain.get_type_name  s,     	:zzTZ444r-   r   rA   c                L    | j                             |j        d          \  }}|S )z,Get type of enumerable nodes (experimental).)NN)rT   ri   rF   )r*   r   enum_node_typer   s       r+   get_enumerable_node_typezDomain.get_enumerable_node_type  s'     155dnlSSr-   c                    dS )z*Return full qualified name for given node.Nr2   )r*   r   s     r+   get_full_qualified_namezDomain.get_full_qualified_name  r   r-   N)rX   r   r#   r$   )r#   r$   )r5   r    rx   r   r#   r$   )r5   r    r#   r|   )r5   r    r#   r   )r8   r    r#   r$   )rG   r   r   rU   r#   r$   )rX   r   r8   r    r   r   r#   r$   )r   r   r#   r$   )rX   r   r   r    r   r   r   r    r   r    r   r   r   r   r#   r   )rX   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#   rA   )r   r   r#   rA   )r.   r/   r0   r1   r5   re   rP   r=   rQ   r!   rR   rS   rT   rV   rc   r,   rw   r{   rz   r   r   r   r   r   r   r   r   r   r   r   r   r2   r-   r+   rD   rD      s         . DE')L))))-/J////02E2222!#G####(*****IKKKKKLJJJL4 4 4 4:	Q 	Q 	Q 	Q	> 	> 	> 	>   &       (   2 2 2 2   
         $" " " "$! ! ! !F5 5 5 5 5   
     r-   rD   )/r1   
__future__r   r(   abcr   r   typingr   r   r   r	   r
   r   docutils.nodesr   r   r   sphinx.errorsr   sphinx.localer   collections.abcr   r   docutilsr   docutils.parsers.rstr   docutils.parsers.rst.statesr   sphinx.addnodesr   sphinx.buildersr   sphinx.environmentr   sphinx.rolesr   sphinx.util.typingr   r   r4   r?   r    TitleGetterrD   r2   r-   r+   <module>r      s>    # " " " " "  # # # # # # # # K K K K K K K K K K K K K K K K 8 8 8 8 8 8 8 8 8 8 % % % % % %       022222222......333333,,,,,,''''''333333%%%%%%//////! ! ! ! ! ! ! !4       U" U" U" U" U"C U" U" U"p vx},-w w w w w w w w w wr-   