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: //usr/lib/python3/dist-packages/sphinx/environment/__pycache__/__init__.cpython-310.pyc
o

o�aRe�@s(UdZddlZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZmZmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lm Z ddl!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1m2Z2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ddl9m:Z:ddl;m<Z<m=Z=e
r�ddl>m?Z?ddl@mAZAe3�BeC�ZDddddddddd dddd!dgd"�ZEe
eFefeGd#<d$ZHd%ZId&ZJd'ZKd(ZLeJe+d)�eKe+d*�eLe+d+�iZMde:d,�ZNe
eFeeOeffeGd-<Gd.d/�d/�ZPdS)0z�
    sphinx.environment
    ~~~~~~~~~~~~~~~~~~

    Global creation environment.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�defaultdict)�copy)�datetime)�path)�
TYPE_CHECKING�Any�Callable�Dict�	Generator�Iterator�List�Optional�Set�Tuple�Union)�nodes)�Node)�addnodes)�Config)�RemovedInSphinx60Warning)�Domain)�TocTree)�BuildEnvironmentError�
DocumentError�ExtensionError�SphinxError)�EventManager)�__)�Project)�SphinxTransformer)�
DownloadFiles�FilenameUniqDict�logging)�LoggingReporter)�CatalogRepository�docname_to_domain)�is_translatable)�
canon_path�os_path)�Sphinx)�Builder�idFTz https://www.python.org/dev/peps/zhttps://tools.ietf.org/html/z	utf-8-sig�)�auto_id_prefix�embed_images�embed_stylesheet�cloak_email_addresses�pep_base_url�pep_references�rfc_base_url�rfc_references�input_encoding�doctitle_xform�sectsubtitle_xform�section_self_link�
halt_level�file_insertion_enabled�smartquotes_locales�default_settings�8����z
new configzconfig changedzextensions changed)�none�text�versioning_conditionsc@s�eZdZUdZeeefed<d_d`dd�Zdefd	d
�Z	deddfdd
�Z
dadd�Zdeddfdd�Z
deddfdd�Zdeeefdeddfdd�Zdeddfdd�Zdeeddddddfdd�Zd edeefd!d"�Zdbded$edefd%d&�Zd_d ededeeeffd'd(�Zedeefd)d*��Zded+d,ddfd-d.�Zd/edeeeeeeeffd0d1�Zddd2eede eddffd3d4�Z!deddfd5d6�Z"edefd7d8��Z#dcd:ede$fd;d<�Z%d eddfd=d>�Z&d eddfd?d@�Z'dddAdB�Z(dCedefdDdE�Z)dede*j+fdFdG�Z,	#	Hdeded+d,dIe*j+dJedKede*j+fdLdM�Z-	H	Hdfded+d,dOe.j/dPedQe$dRedSedKede0fdTdU�Z1dIe*j+dVed+d,ddfdWdX�Z2dIe*j+deddfdYdZ�Z3deeeeeffd[d\�Z4ddd]d^�Z5dS)g�BuildEnvironmentz�
    The environment in which the ReST files are translated.
    Stores an inventory of cross-file targets and provides doctree
    transformations to resolve links to them.
    �domainsN�appr)cCsd|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
i|_t�
�|_||jd<i|_tt�|_tt�|_t�|_tt�|_i|_i|_i|_i|_i|_i|_i|_i|_t�|_t�|_ i|_!t"�|_#t$�|_%i|_&i|_'i|_(|r�|�)|�dSt*j+dt,dd�dS)N�envz?The 'app' argument for BuildEnvironment() becomes required now.r?)�
stacklevel)-rG�
doctreedir�srcdir�config�
config_status�config_status_extra�events�project�version�versioning_condition�versioning_comparerFr<r�settings�all_docsr�set�dependencies�included�
reread_always�dict�metadata�titles�
longtitles�tocs�toc_num_entries�toc_secnumbers�toc_fignumbers�toctree_includes�files_to_rebuild�
glob_toctrees�numbered_toctrees�
domaindatar!�imagesr �dlfiles�original_image_uri�	temp_data�ref_context�setup�warnings�warnr)�selfrG�rp�=/usr/lib/python3/dist-packages/sphinx/environment/__init__.py�__init__csP





�zBuildEnvironment.__init__�returncCs|j��}|jdidd�|S)z'Obtains serializable data for pickling.N)rGrFrO)�__dict__r�update)rortrprprq�__getstate__�s
zBuildEnvironment.__getstate__�statecCs|j�|�dS�N)rtru)rorwrprprq�__setstate__�szBuildEnvironment.__setstate__cCs�|jr|j|j�|�krttd���|jr!|j|jkr!ttd���|jr+|j�|j�||_|j	|_	|j
|_
|j|_|j|_|j�|�|_i|_|j�|�D]}||j|j
<qN|j��D]}|��q\|�|j�|�|j�dS)zSet up BuildEnvironment object.z%build environment version not currentzsource directory has changedN)rQ�registry�get_envversionrrrKrP�restorerGrJrOrF�create_domains�name�valuesrl�_update_configrL�_update_settings)rorG�domainrprprqrl�s&
zBuildEnvironment.setuprLcCs�t|_d|_|jdurt|_nM|jj|jkr?t|_tt|jj�t|j�A�}t	|�dkr1|d}ndt	|�f}d|f|_n|�
d�D]}|j|j|jkr[t
|_d|jf|_nqD||_dS)z!Update configurations by new one.�Nr>rz%dz (%r)rH)�	CONFIG_OKrMrNrL�
CONFIG_NEW�
extensions�CONFIG_EXTENSIONS_CHANGED�sortedrV�len�filterr~�value�CONFIG_CHANGED)rorLr��	extension�itemrprprqr��s(
�
�
zBuildEnvironment._update_configcCs:|j|jd<|j|jd<|jpd|jd<|j�dd�dS)zUpdate settings by new config.r5�trim_footnote_reference_space�en�
language_code�smart_quotesTN)�source_encodingrTr��language�
setdefault)rorLrprprqr�sz!BuildEnvironment._update_settings�method�comparecCsTt|�r|}n|tvrtd|��t|}|jd|fvr"ttd���||_||_dS)aXThis sets the doctree versioning method for this environment.

        Versioning methods are a builder property; only builders with the same
        versioning method can share the same doctree directory.  Therefore, we
        raise an exception if the user tries to use an environment with an
        incompatible versioning method.
        zinvalid versioning method: %rNzdThis environment is incompatible with the selected builder, please choose another doctree directory.)�callablerD�
ValueErrorrRrrrS)ror�r��	conditionrprprq�set_versioning_method
s	
z&BuildEnvironment.set_versioning_method�docnamecCsP||jvr|j�|d�|j�|d�|j�|�|j��D]}|�|�qdS)z4Remove all traces of a source file in the inventory.N)rU�poprXrY�discardrFr�	clear_doc)ror�r�rprprqr�$s
�zBuildEnvironment.clear_doc�docnames�othercCs�t|�}|D]}|j||j|<|j||j|<||jvr#|j�|�q|j��D]
\}}|�||j|�q)|j	�
d|||�dS)z�Merge global information gathered about *docnames* while reading them
        from the *other* environment.

        This possibly comes from a parallel build process.
        zenv-merge-infoN)rVrUrXrY�addrF�items�merge_domaindatarfrO�emit)ror�r�rGr��
domainnamer�rprprq�merge_info_from.s
�z BuildEnvironment.merge_info_from�filenamecCs|j�|�S)z�Return the docname for the filename if the file is document.

        *filename* should be absolute or relative to the source directory.
        )rP�path2doc�ror�rprprqr�@szBuildEnvironment.path2docT�basecCs|j�||�S)z�Return the filename for the document name.

        If *base* is True, return absolute path under self.srcdir.
        If *base* is False, return relative path to self.srcdir.
        )rP�doc2path)ror�r�rprprqr�GszBuildEnvironment.doc2pathcCstt|�}|�d�s|�tj�r|dd�}nt�|j|p|jdd��}t�||�}t	t�
|��t�
t�|j|��fS)a+Return paths to a file referenced from a document, relative to
        documentation root and absolute.

        In the input "filename", absolute filenames are taken as relative to the
        source dir, while relative filenames are relative to the dir of the
        containing document.
        �/r>N)r�)r(�
startswith�os�sepr�dirnamer�r��joinr'�normpathrK)ror�r��rel_fn�docdirrprprq�
relfn2pathOs��zBuildEnvironment.relfn2pathcCs|jjS)zcontains all existing docnames.)rPr��rorprprq�
found_docsbszBuildEnvironment.found_docs�builderr*c	
Cs�zL|jj|jj|��}|j�|�|jrGt|j|jj	|jj
|jj�}dd�|jD�}|j
D]}t||jj�}||vrF|j|�||�q/WdSWdStyd}zttd�|j|f�|�d}~ww)zYFind all source files in the source dir and put them in
        self.found_docs.
        cSsi|]}|j|j�qSrp)r��mo_path)�.0�crprprq�
<dictcomp>{sz/BuildEnvironment.find_files.<locals>.<dictcomp>z"Failed to scan documents in %s: %rN)rL�exclude_patterns�templates_path�get_asset_pathsrP�discover�use_message_catalogr$rK�locale_dirsr�r��catalogsr�r%�gettext_compactrWr��OSErrorrr)	rorLr��
exclude_paths�repo�mo_pathsr�r��excrprprq�
find_filesgs6���
������zBuildEnvironment.find_files�config_changedc
Cs|t|j�|j}t�}t�}|r|j}n�|jD]�}||jvr*t�d|�|�|�qt�|j|d�}t�	|�sDt�d|�|�|�q||j
vrUt�d|�|�|�q|j|}t�|�|��}||krzt�d|t
�|�t
�|��|�|�q|j|D]8}	z't�|j|	�}
t�	|
�s�|�|�Wn"t�|
�}||kr�|�|�WnWqty�|�|�Ynwq|||fS)z&Return (added, changed, removed) sets.z[build target] added %r�.doctreez[build target] changed %rz$[build target] outdated %r: %s -> %s)rVrUr��logger�debugr�rr�rJ�isfilerY�getmtimer�r�utcfromtimestamprWrKr�)ror��removed�added�changedr�r��mtime�newmtime�dep�deppath�depmtimerprprq�get_outdated_files�s\







�




�
��
z#BuildEnvironment.get_outdated_files�alreadyccsD�g}|j�d|�D]}|�|�q
t|�D]	}||vr|VqdS)Nzenv-get-updated)rOr��extendrV)rorGr��
to_rewriter�r�rprprq�check_dependents�s���z!BuildEnvironment.check_dependentscCs2||jd<|jj|jd<|j�|jj�|jd<dS)z*Prepare to set up environment for reading.r��default_role�default_domainN)rjrLr�rF�get�primary_domain)ror�rprprq�prepare_settings�s
�z!BuildEnvironment.prepare_settingscCs
|jdS)z;Returns the docname of the document currently being parsed.r�)rjr�rprprqr��s
zBuildEnvironment.docnamer��categorycCs(|d}|j�|d�}|d|j|<|S)z�Return a serial number, e.g. for index entry targets.

        The number is guaranteed to be unique in the current document.
        �serialnorr>)rjr�)ror��key�currprprq�new_serialno�szBuildEnvironment.new_serialnocCs|j|j�|�dS)z�Add *filename* as a dependency of the current document.

        This means that the document will be rebuilt if this file changes.

        *filename* should be absolute or relative to the source directory.
        N)rWr�r�r�rprprq�note_dependency�sz BuildEnvironment.note_dependencycCs|j|j�|�|��dS)z�Add *filename* as a included from other document.

        This means the document is not orphaned.

        *filename* should be absolute or relative to the source directory.
        N)rXr�r�r�r�rprprq�
note_included�szBuildEnvironment.note_includedcCs|j�|j�dS)zxAdd the current document to the list of documents that will
        automatically be re-read at the next build.
        N)rYr�r�r�rprprq�note_reread�szBuildEnvironment.note_rereadr�c
Cs8z|j|WSty}z	ttd�|�|�d}~ww)zReturn the domain instance with the specified name.

        Raises an ExtensionError if the domain is not registered.
        zDomain %r is not registeredN)rF�KeyErrorrr)ror�r�rprprq�
get_domain�s��zBuildEnvironment.get_domaincCsbt�|j|d�}t|d��
}t�|�}Wd�n1swY||j_t|�	|��|_
|S)z:Read the doctree for a file from the pickle and return it.r��rbN)rr�rJ�open�pickle�loadrTrHr#r��reporter)ror�r��f�doctreerprprq�get_doctrees�zBuildEnvironment.get_doctreeFr��prune_toctrees�
includehiddencCsj|dur	|�|�}|�||�|�tj�D]}t|�j|||||d�}|dur-|�g�q|�|�q|S)zgRead the doctree from the pickle, resolve cross-references and
        toctrees and return it.
        N)�pruner�)r��apply_post_transforms�traverser�toctreer�resolve�replace_self)ror�r�r�r�r��toctreenode�resultrprprq�get_and_resolve_doctree
s
�z(BuildEnvironment.get_and_resolve_doctreerr�r��maxdepth�titles_only�collapsec		
Cst|��||||||||�S)aResolve a *toctree* node into individual bullet lists with titles
        as items, returning None (if no containing titles are found) or
        a new node.

        If *prune* is True, the tree is pruned to *maxdepth*, or if that is 0,
        to the value of the *maxdepth* option on the *toctree* node.
        If *titles_only* is True, only toplevel document titles will be in the
        resulting tree.
        If *collapse* is True, all branches not containing docname will
        be collapsed.
        )rr�)	ror�r�r�r�rrrr�rprprq�resolve_toctree%s�z BuildEnvironment.resolve_toctree�fromdocnamecCs|�||�dSrx)r�)ror�rr�rprprq�resolve_references7sz#BuildEnvironment.resolve_referencescCshz%t|j�}||jd<t|�}|�|�|�|jj���|��W||_n||_w|j	�
d||�dS)zApply all post-transforms.r�zdoctree-resolvedN)rrjr�set_environment�add_transformsrGrz�get_post_transforms�apply_transformsrOr�)ror�r��backup�transformerrprprqr�;s



z&BuildEnvironment.apply_post_transformsc	s�t��dtdtdttttff���fdd��i}�d�jj�}d}t|�\}}|D]\}}|||g||<|}|}|}q+||dg||<|S)N�parentr�rsc3s��||krtjtd�|ddd�dS||fV��|��j�|�p#gD]}�||�D]\}}|�vr=||fV��|�q+q$dS)Nz'self referenced toctree found. Ignored.�toc�circular)�location�type�subtype)r��warningrr�rbr�)rr��child�	subparent�
subdocname�ro�traverse_toctree�	traversedrprqrOs"�
�



���z<BuildEnvironment.collect_relations.<locals>.traverse_toctree)rV�strrrrL�root_doc�next)ro�	relationsr��prevdocrr��
nextparent�nextdocrprrq�collect_relationsLs*z"BuildEnvironment.collect_relationscCs�t�j|j���}t|j�D]$}||jvr2||jjkrq||vr!qd|j	|vr)qt
jtd�|d�q|j
��D]}|��q8|j�d|�dS)zDo consistency checks.�orphanz&document isn't included in any toctree)rzenv-check-consistencyN)rV�unionrXrr�rUrcrLrr[r�rrrF�check_consistencyrOr�)rorXr�r�rprprqr%ns 

��
z"BuildEnvironment.check_consistencyrx)rGr))rGr)rsN)T)r�)rsN)NTF)TrFFF)6�__name__�
__module__�__qualname__�__doc__r	rr�__annotations__rrrvryrlrr�r�rr�boolr�r�rr�r
r�r�rr��propertyrr�r�r�r
r�r�r��intr�r�r�r�r�r�documentr�rrr�rrrr�r"r%rprprprqrEXs�
^
 	
�
� ($9


	
	
����
�������
��
�"rE)Qr)r�r�rm�collectionsrrrr�typingrrrr	r
rrr
rrr�docutilsr�docutils.nodesr�sphinxr�
sphinx.configr�sphinx.deprecationr�sphinx.domainsr�#sphinx.environment.adapters.toctreer�
sphinx.errorsrrrr�
sphinx.eventsr�
sphinx.localer�sphinx.projectr�sphinx.transformsr�sphinx.utilr r!r"�sphinx.util.docutilsr#�sphinx.util.i18nr$r%�sphinx.util.nodesr&�sphinx.util.osutilr'r(�sphinx.applicationr)�sphinx.buildersr*�	getLoggerr&r�r<rr*�ENV_VERSIONr�r�r�r��CONFIG_CHANGED_REASONrDr+rErprprprq�<module>sv
4
���