HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/sphinx/util/__pycache__/docutils.cpython-310.pyc
o

�$�a"J�@s�UdZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZddlZddlmZdd	lmZdd
lmZmZmZddlmZm Z m!Z!ddl"m#Z#dd
l$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4e2�5e6�Z7e�8d�Z9er�ddl:m;Z;ddl<m=Z=ddl>m?Z?e,�@ejA�jBZCeD�ZEeeeeFd<ededfdd��ZGdeHdeIfdd�ZJdeHd eeddfd!d"�ZKdeHdeIfd#d$�ZLdeHd%e4ddfd&d'�ZMdeHddfd(d)�ZNd*eedeIfd+d,�ZOd*eeddfd-d.�ZPd*eeddfd/d0�ZQededfd1d2��ZRed3eeHdedfd4d5��ZSedWd3eeHdedfd6d7��ZTGd8d9�d9eU�ZVGd:d;�d;�ZWGd<d=�d=�ZXGd>d?�d?e)�ZYGd@dA�dAe)�ZZdeIfdBdC�Z[edDe%dEe'dedfdFdG��Z\GdHdI�dIe�Z]GdJdK�dKe�Z^GdLdM�dM�Z_GdNdO�dOe_�Z`GdPdQ�dQeja�ZbdaceejdeFdR<dWdSeHdTedejdfdUdV�ZedS)Xz�
    sphinx.util.docutils
    ~~~~~~~~~~~~~~~~~~~~

    Utility functions for docutils.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�contextmanager)�copy)�path)�
ModuleType)�IO�
TYPE_CHECKING�Any�Callable�Dict�	Generator�List�Optional�Set�Tuple�Type�cast)�nodes)�
FileOutput)�Element�Node�system_message)�	Directive�
directives�roles)�Inliner)�State�StateMachine�
StringList)�Reporter�unescape)�version)�SphinxError)�_)�logging)�RoleFunctionz>^(.+?:(?:\d+)?): \((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\d+)?\) )�Builder)�Config)�BuildEnvironment�additional_nodes�return)NNNc
cs~�z&ttj�}ttj�}dVW|t_|t_tt�D]}t|�t�|�qdS|t_|t_tt�D]}t|�t�|�q2w)z"Create namespace for reST parsers.N)	rr�_directivesr�_roles�listr(�unregister_node�discard)r*r+�node�r0�6/usr/lib/python3/dist-packages/sphinx/util/docutils.py�docutils_namespace0s"�

���r2�namecC�
|tjvS)z1Check the *name* directive is already registered.)rr*�r3r0r0r1�is_directive_registeredA�
r6�	directivecC�t�||�dS)z�Register a directive to docutils.

    This modifies global state of docutils.  So it is better to use this
    inside ``docutils_namespace()`` to prevent side-effects.
    N)r�register_directive)r3r8r0r0r1r:F�r:cCr4)z,Check the *name* role is already registered.)rr+r5r0r0r1�is_role_registeredOr7r<�rolecCr9)z�Register a role to docutils.

    This modifies global state of docutils.  So it is better to use this
    inside ``docutils_namespace()`` to prevent side-effects.
    N)r�register_local_role)r3r=r0r0r1�
register_roleTr;r?cCstj�|d�dS)z Unregister a role from docutils.N)rr+�popr5r0r0r1�unregister_role]�rAr/cCsttjd|j�S)z'Check the *node* is already registered.�visit_)�hasattrr�GenericNodeVisitor�__name__�r/r0r0r1�is_node_registeredbrBrHcCs2ttjd|j�st�|jg�t�|�dSdS)z�Register a node to docutils.

    This modifies global state of some visitors.  So it is better to use this
    inside ``docutils_namespace()`` to prevent side-effects.
    rCN)rDrrErF�_add_node_class_namesr(�addrGr0r0r1�
register_nodegs�rKcCsbttjd|j�r/ttjd|j�ttjd|j�ttjd|j�ttjd|j�dSdS)zaUnregister a node from docutils.

    This is inverse of ``nodes._add_nodes_class_names()``.
    rC�depart_N)rDrrErF�delattr�SparseNodeVisitorrGr0r0r1r-rs�r-c#sR�ddlm�d	dtdtdtf�fdd�
}z|tj_dVW�tj_dS�tj_w)
z�Patch docutils.languages.get_language() temporarily.

    This ignores the second argument ``reporter`` to suppress warnings.
    refs: https://github.com/sphinx-doc/sphinx/issues/3788
    r��get_languageN�
language_code�reporterr)cs�|�S�Nr0)rQrRrOr0r1�patched_get_language��z2patched_get_language.<locals>.patched_get_languagerS)�docutils.languagesrP�strrr�docutils�	languages)rTr0rOr1rT~s�rT�confdirc
cs��z-tj�dd�}|rt�t�|�d�tjd<dVW|dur(tj�dd�dS|tjd<dS|dur;tj�dd�w|tjd<w)z?Let docutils know the location of ``docutils.conf`` for Sphinx.�DOCUTILSCONFIGNz
docutils.conf)�os�environ�getr�join�abspathr@)rZ�docutilsconfigr0r0r1�using_user_docutils_conf�s��rbc	csl�t��(t|��dVWd�n1swYWd�dSWd�dS1s/wYdS)zPatch to docutils temporarily.N)rTrb)rZr0r0r1�patch_docutils�s�P�rcc@seZdZdS)�ElementLookupErrorN)rF�
__module__�__qualname__r0r0r0r1rd�srdc
@s�eZdZdZd!dd�Zd"dd	�Zd
eedededdfd
d�Z	d"dd�Z
d"dd�Zdededefdd�Z
dededejdeeeeeeffdd�Zdededededeeeeff
dd �ZdS)#�sphinx_domainszcMonkey-patch directive and role dispatch, so that domain-specific
    markup takes precedence.
    �envr'r)NcCs||_dd�|_dd�|_dS)NcW�dgfSrSr0��argsr0r0r1�<lambda>��z)sphinx_domains.__init__.<locals>.<lambda>cWrirSr0rjr0r0r1rl�rm)rh�directive_func�
roles_func)�selfrhr0r0r1�__init__�s
zsphinx_domains.__init__cC�|��dSrS)�enable�rpr0r0r1�	__enter__��zsphinx_domains.__enter__�exc_type�	exc_value�	tracebackcCrrrS)�disable)rprwrxryr0r0r1�__exit__�rvzsphinx_domains.__exit__cCs$tj|_tj|_|jt_|jt_dSrS)rr8rnrr=�	role_func�lookup_directive�lookup_rolertr0r0r1rs�szsphinx_domains.enablecCs|jt_|jt_dSrS)rnrr8r|rr=rtr0r0r1rz�szsphinx_domains.disable�typer3cCs�|��}d|vr6|�dd�\}}||jjvr,|j�|�}t||�|�}|dur+|gfSn$t�td�||�n|jj	�
d�}|durPt||�|�}|durP|gfSt|j�d�|�|�}|durc|gfSt�)ztLookup a markup element (directive or role), given its name which can
        be a full name (with domain).
        �:�Nz%unknown directive or role name: %s:%s�default_domain�std)�lower�splitrh�domains�
get_domain�getattr�logger�warningr"�	temp_datar^rd)rprr3�domain_name�domain�element�
def_domainr0r0r1�lookup_domain_element�s&�z$sphinx_domains.lookup_domain_element�directive_name�language_module�documentcCs0z|�d|�WSty|�|||�YSw)Nr8)r�rdrn)rpr�r�r�r0r0r1r}�s
�zsphinx_domains.lookup_directive�	role_name�linenorRc	Cs2z|�d|�WSty|�||||�YSw)Nr=)r�rdr|)rpr�r�r�rRr0r0r1r~�s
�zsphinx_domains.lookup_role)rhr'r)N�r)N)rFrerf�__doc__rqrur�	Exceptionrr{rsrzrWr�rrr�rr
rrrr}�intrr$r~r0r0r0r1rg�s



0.rgc@seZdZdeddfdd�ZdS)�
WarningStream�textr)NcCsTt�|�}|st�|�d��dS|��\}}}t�d|���}tj|||d�dS)Nz
�)�location)�	report_re�searchr�r��rstrip�groups�sub�log)rpr��matchedr�r�level�messager0r0r1�write�s
zWarningStream.write)rFrerfrWr�r0r0r0r1r��sr�c
sZeZdZededdfdd��Zejejddfdede	d	e	d
e
deddf�fd
d�
Z�ZS)�LoggingReporterrRr)cCs||j|j|j|j|j�S)zACreate an instance of LoggingReporter from other reporter object.)�source�report_level�
halt_level�
debug_flag�
error_handler)�clsrRr0r0r1�
from_reporter�s�zLoggingReporter.from_reporterF�backslashreplacer�r�r��debugr�Ncs(ttt��}t�j||||||d�dS)N)r�)rrr��superrq)rpr�r�r�r�r��stream��	__class__r0r1rqs
�zLoggingReporter.__init__)
rFrerf�classmethodrr��
WARNING_LEVEL�SEVERE_LEVELrWr��boolrq�
__classcell__r0r0r�r1r��s�����r�cs"eZdZdZd�fdd�Z�ZS)�NullReporterz A dummy reporter; write nothing.r)Ncst��ddd�dS)Nr�i��)r�rqrtr�r0r1rqszNullReporter.__init__r�)rFrerfr�rqr�r0r0r�r1r�sr�cCstdkS)N)r�
r)�__version_info__r0r0r0r1�is_html5_writer_availablerUr��state�contentccsL�z|jjj}tgd�}||_|j|jj_dVW||jj_dS||jj_w)z1Switch current source input of state temporarily.N)�memorR�get_source_and_liner�input_lines)r�r�r��
state_machiner0r0r1�switch_source_inputs�

r�cs@eZdZdZdeddf�fdd�Zdedef�fdd	�Z�ZS)
�SphinxFileOutputz#Better FileOutput class for Sphinx.�kwargsr)Ncs$|�dd�|_t�jdi|��dS)N�overwrite_if_changedFr0)r@r�r�rq)rpr�r�r0r1rq,szSphinxFileOutput.__init__�datacs�|jr<|jr<d|jvr<|jr<tj�|j�r<t|j|jd��}|�	�|kr-|Wd�SWd�n1s7wYt
��|�S)N�b)�encoding)�destination_path�	autoclose�moder�r\r�exists�openr��readr�r�)rpr��fr�r0r1r�0s����zSphinxFileOutput.write)	rFrerfr�rrqrWr�r�r0r0r�r1r�)sr�c@sbeZdZdZeddd��Zeddd��Zdeee	ffd	d
�Z
deddfd
d�Zdefdd�Z
dS)�SphinxDirectivez�A base class for Sphinx directives.

    This class provides helper methods for Sphinx directives.

    .. note:: The subclasses of this class might not work with docutils.
              This class is strongly coupled with Sphinx.
    r)r'cC�|jjjjS�z3Reference to the :class:`.BuildEnvironment` object.)r�r��settingsrhrtr0r0r1rhD�zSphinxDirective.envr&cC�|jjS�z)Reference to the :class:`.Config` object.�rh�configrtr0r0r1r�I�zSphinxDirective.configcCs|j�|j�S)zGet source and line number.)r�r�r�rtr0r0r1�get_source_infoNszSphinxDirective.get_source_infor/NcCs|��\|_|_dS)z'Set source and line number to the node.N�r�r��line)rpr/r0r0r1�set_source_infoRszSphinxDirective.set_source_infocC�d�dd�|��D��S)�&Get current location info for logging.r�cs��|]}t|�VqdSrS�rW��.0�sr0r0r1�	<genexpr>X��z/SphinxDirective.get_location.<locals>.<genexpr>�r_r�rtr0r0r1�get_locationV�zSphinxDirective.get_location�r)r'�r)r&)rFrerfr��propertyrhr�rrWr�r�rr�r�r0r0r0r1r�;sr�c@seZdZUdZeed<eed<eed<eed<eed<eed<e	eed<igfdedededededede	ed	e
e	ee	effd
d�Z
d	e
e	ee	effdd
�Zeddd��Zeddd��Zdded	e
eeffdd�Zddeded	dfdd�Zd	efdd�ZdS)�
SphinxRolez�A base class for Sphinx roles.

    This class provides helper methods for Sphinx roles.

    .. note:: The subclasses of this class might not work with docutils.
              This class is strongly coupled with Sphinx.
    r3�rawtextr�r��inliner�optionsr�r)cCsx||_t|�|_||_||_||_||_|r|��|_|��S|j	j
�dd�|_|js1|j	jj
|_|js8td��|��S)N�default_roler�zcannot determine default role!)r�rr�r�r�r�r�r�r3rhr�r^r�r�r!�run)rpr3r�r�r�r�r�r�r0r0r1�__call__ms

�zSphinxRole.__call__cCst�rS)�NotImplementedErrorrtr0r0r1r��szSphinxRole.runr'cCr�r�)r�r�r�rhrtr0r0r1rh�r�zSphinxRole.envr&cCr�r�r�rtr0r0r1r��r�zSphinxRole.configNcCs|dur|j}|jj�|�SrS)r�r�rRr�)rpr�r0r0r1r��szSphinxRole.get_source_infor/cCs|�|�\|_|_dSrSr�)rpr/r�r0r0r1r��szSphinxRole.set_source_infocCr�)r�r�csr�rSr�r�r0r0r1r��r�z*SphinxRole.get_location.<locals>.<genexpr>r�rtr0r0r1r��r�zSphinxRole.get_locationr�r�rS)rFrerfr�rW�__annotations__r�rr
rrrrr�r�r�rhr�r�r�r�r0r0r0r1r�[s6
����
�r�cs�eZdZUdZeed<eed<eed<eed<e�dej	�Z
igfdeded	ed
edede
d
eedeeeeeff�fdd�
Z�ZS)�
ReferenceRolez�A base class for reference roles.

    The reference roles can accept ``link title <target>`` style as a text for
    the role.  The parsed result; link title and target will be stored to
    ``self.title`` and ``self.target``.
    �has_explicit_title�disabled�title�targetz^(.+?)\s*(?<!\x00)<(.*?)>$r3r�r�r�r�r�r�r)c		sv|�d�|_|j�|�}|r"d|_t|�d��|_t|�d��|_n
d|_t|�|_t|�|_t	��
|||||||�S)N�!Tr��F)�
startswithr��explicit_title_re�matchr�r�groupr�r�r�r�)	rpr3r�r�r�r�r�r�r�r�r0r1r��s

zReferenceRole.__call__)rFrerfr�r�r�rW�re�compile�DOTALLrr�rr
rrrrr�r�r0r0r�r1r��s"
�����r�cs\eZdZdZdejddddf�fdd�Zd	eddf�fd
d�Zd	eddf�fdd
�Z	�Z
S)�SphinxTranslatoraxA base class for Sphinx translators.

    This class adds a support for visitor/departure method for super node class
    if visitor/departure method for node class is not found.

    It also provides helper methods for Sphinx translators.

    .. note:: The subclasses of this class might not work with docutils.
              This class is strongly coupled with Sphinx.
    r��builderr%r)Ncs&t��|�||_|j|_|j|_dSrS)r�rqr	r�r�)rpr�r	r�r0r1rq�szSphinxTranslator.__init__r/c�B|jjD]}t|d|jd�}|r||�dSqt��|�dS)z�
        Dispatch node to appropriate visitor method.
        The priority of visitor method is:

        1. ``self.visit_{node_class}()``
        2. ``self.visit_{super_node_class}()``
        3. ``self.unknown_visit()``
        zvisit_%sN)r��__mro__r�rFr��dispatch_visit�rpr/�
node_class�methodr�r0r1r��	�zSphinxTranslator.dispatch_visitcr
)z�
        Dispatch node to appropriate departure method.
        The priority of departure method is:

        1. ``self.depart_{node_class}()``
        2. ``self.depart_{super_node_class}()``
        3. ``self.unknown_departure()``
        z	depart_%sN)r�rr�rFr��dispatch_departurer
r�r0r1r�rz#SphinxTranslator.dispatch_departure)rFrerfr�rr�rqrrrr�r0r0r�r1r�s
r�__document_cache__�source_pathr�cCsTtdur
tj�|�a|durttj�}ddlm}|j|tj	|d�}|�
|d�|S)a&Return a new empty document object.  This is an alternative of docutils'.

    This is a simple wrapper for ``docutils.utils.new_document()``.  It
    caches the result of docutils' and use it on second call for instantiation.
    This makes an instantiation of document nodes much faster.
    Nr)�addnodes)r����)rrX�utils�new_documentrr��sphinxrr�rR�note_source)rr�rr�r0r0r1r�s
rrS)fr�r\r�
contextlibrrr�typesr�typingrrrr	r
rrr
rrrrrXr�docutils.ior�docutils.nodesrrr�docutils.parsers.rstrrr�docutils.parsers.rst.statesr�docutils.statemachinerrr�docutils.utilsrr�	packagingr �
sphinx.errorsr!�
sphinx.localer"�sphinx.utilr#�sphinx.util.typingr$�	getLoggerrFr�rr��sphinx.buildersr%�
sphinx.configr&�sphinx.environmentr'�parse�__version__�releaser��setr(r�r2rWr�r6r:r<r?rArHrKr-rTrbrcr�rdrgr�r�r�r�r�r�r�r�r��NodeVisitorrrr�rr0r0r0r1�<module>sx
8

		E B"7