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/builders/__pycache__/__init__.cpython-310.pyc
o

�$�azc�@s�dZddlZddlZddlmZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZddlmZddlmZddlmZmZmZdd	lmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;m<Z<m=Z=m>Z>ddl?m@Z@ddlAmBZBddlAmCZCzddlDZDWneEy�dZDYnwer�ddlFmGZGe'�HeI�ZJGdd�d�ZKdS)z�
    sphinx.builders
    ~~~~~~~~~~~~~~~

    Builder superclass for all builders.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�path)�
TYPE_CHECKING�Any�Dict�Iterable�List�Optional�Sequence�Set�Tuple�Type�Union)�nodes)�Node)�Config)�CONFIG_CHANGED_REASON�	CONFIG_OK�BuildEnvironment)�ImageAdapter)�SphinxError)�EventManager)�read_doc)�__)�
import_object�logging�progress_message�rst�status_iterator)�
BuildPhase)�bold)�sphinx_domains)�CatalogInfo�CatalogRepository�docname_to_domain)�SEP�	ensuredir�relative_uri�relpath)�
ParallelTasks�SerialTasks�make_chunks�parallel_available)�Tags)�
directives)�roles)�Sphinxc	@s�eZdZUdZdZdZdZdZee	j
ed<dZdZ
dZdZgZeeed<dZdZdbdd
�Zdeddfdd�Zdedee	j
fdd�Zdede	j
fdd�Zdcdd�Zdcdd�Zdddededefdd�Zdddedededefd d!�Zdeee effd"d#�Z!deefd$d%�Z"d&e#ddfd'd(�Z$d)e%e&d*eddfd+d,�Z'dcd-d.�Z(d/eeddfd0d1�Z)dcd2d3�Z*dcd4d5�Z+d6eeddfd7d8�Z,dcd9d:�Z-ded<e ed=ed>eddfd?d@�Z.deefdAdB�Z/d<eeddfdCdD�Z0d<eedEe1ddfdFdG�Z2deddfdHdI�Z3ded&e	j4ddfdJdK�Z5dfdLe edMe6ed>eddfdNdO�Z7d<e6eddfdPdQ�Z8d<e6edEe1ddfdRdS�Z9d<e%eddfdTdU�Z:ded&e	j4ddfdVdW�Z;ded&e	j4ddfdXdY�Z<dcdZd[�Z=dcd\d]�Z>d^ed_edefd`da�Z?dS)g�Builderz6
    Builds target formats from the reST sources.
    �N�default_translator_class�noneFT�supported_image_types�appr/�returncCs�|j|_|j|_|j|_|j|_t|j�||_d|_|j|_|j|_|j	|_	|j	�
|j�|j	�
|j�|j	�
d|j�|j	�
d|j�i|_
d|_d|_d|_d|_dS)Nz	format_%sz
builder_%sr1F)�srcdir�confdir�outdir�
doctreedirr%r5�env�events�config�tags�add�format�name�images�imagedir�imgpath�parallel_ok�finish_tasks)�selfr5�rH�:/usr/lib/python3/dist-packages/sphinx/builders/__init__.py�__init__Ts&

zBuilder.__init__r;cCs||_|j�|j|j�dS)zStore BuildEnvironment object.N)r;�set_versioning_method�versioning_method�versioning_compare)rGr;rHrHrI�set_environmentps
�zBuilder.set_environment�argscGs|jj�|�S)zReturn a class of translator.)r5�registry�get_translator_class�rGrOrHrHrIrQvszBuilder.get_translator_classcGs|jjj|g|�R�S)z�Return an instance of translator.

        This method returns an instance of ``default_translator_class`` by default.
        Users can replace the translator class with ``app.set_translator()`` API.
        )r5rP�create_translatorrRrHrHrIrSzszBuilder.create_translatorcC�dS)zoLoad necessary templates and perform initialization.  The default
        implementation does nothing.
        NrH�rGrHrHrI�init��zBuilder.initcCs6|jjrt|jjd��|_dSddlm}|�|_dS)z&Return the template bridge configured.ztemplate_bridge settingr)�BuiltinTemplateLoaderN)r=�template_bridger�	templates�sphinx.jinja2gluerX)rGrXrHrHrI�create_template_bridge�s�zBuilder.create_template_bridge�docname�typcC�t�)z�Return the target URI for a document name.

        *typ* can be used to qualify the link characteristic for individual
        builders.
        ��NotImplementedError)rGr]r^rHrHrI�get_target_uri�szBuilder.get_target_uri�from_�tocCst|�|�|�||��S)z�Return a relative URI between two source filenames.

        May raise environment.NoUri if there's no way to return a sensible URI.
        )r&rb)rGrcrdr^rHrHrI�get_relative_uri�s

�zBuilder.get_relative_uricCr_)aDReturn an iterable of output files that are outdated, or a string
        describing what an update build will build.

        If the builder does not output individual files corresponding to
        source files, return a string here.  If it does, return an iterable
        of those files that need to be written.
        r`rUrHrHrI�get_outdated_docs�szBuilder.get_outdated_docscCsgS)z;Return list of paths for assets (ex. templates, CSS, etc.).rHrUrHrHrI�get_asset_paths��zBuilder.get_asset_paths�doctreecCs�t|j�}|�tj�D]f}d|dvrqd|dvr[|jD]}|d�|d�}|r+n+qt|d�}|�|d�}|rIt	j
td�|j|||d�nt	j
td�|j||d�q||d<n|d}||jj
vrfq|jj
|d	|j
|<qdS)
z+Pick the best candidate for all image URIs.�?�
candidates�*N�uriz2a suitable image for %s builder not found: %s (%s))�locationz-a suitable image for %s builder not found: %s�)rr;�traverser�imager4�get�sorted�get_original_image_uri�logger�warningrrArB)rGrirB�node�imgtype�	candidate�	mimetypes�	image_urirHrHrI�post_process_images�s4

�

�
�
�zBuilder.post_process_images�catalogs�messagecsv�jjsdSdtdtf�fdd�}t�ttd��|�t|td�dt	|��j
j|d�D]}|��jj
�jj�q,dS)	N�catr6cst|j�jj��tjt�S�N)r'�mo_pathr;r7�replacer�sepr$)rrUrHrI�cat2relpath�sz-Builder.compile_catalogs.<locals>.cat2relpathzbuilding [mo]: �writing output... �	darkgreen)�stringify_func)r=�gettext_auto_buildr!�strru�inforrr�lenr5�	verbosity�write_mo�language� gettext_allow_fuzzy_translations)rGr}r~r��catalogrHrUrI�compile_catalogs�s
�
��zBuilder.compile_catalogscCsHt|j|jj|jj|jj�}td�tt|j	��}|�
t|j	�|�dS)Nzall of %d po files)r"r7r=�locale_dirsr��source_encodingrr��listr}r��set)rG�repor~rHrHrI�compile_all_catalogs�s
�zBuilder.compile_all_catalogs�specified_filescs�dtdttf�fdd�}t�}tt||��}t�j�jj�jj�jj	�}|j
D]}|j|vr8|��r8|�
|�q(td�t|�}��||�dS)N�fpathr6cs(�j�t�|��}|rt|�jj�SdSr�)r;�path2docr�abspathr#r=�gettext_compact)r�r]rUrHrI�	to_domain�sz4Builder.compile_specific_catalogs.<locals>.to_domainz*targets for %d po files that are specified)r�rr��mapr"r7r=r�r�r�r}�domain�is_outdatedr?rr�r�)rGr�r�r}�domainsr�r�r~rHrUrI�compile_specific_catalogs�s�

�z!Builder.compile_specific_catalogscCsLt|j|jj|jj|jj�}dd�|jD�}td�t|�}|�	||�dS)NcSsh|]}|��r|�qSrH)r�)�.0�crHrHrI�	<setcomp>�sz2Builder.compile_update_catalogs.<locals>.<setcomp>z,targets for %d po files that are out of date)
r"r7r=r�r�r�r}rr�r�)rGr�r}r~rHrHrI�compile_update_catalogs�s�zBuilder.compile_update_catalogscCs|jdtd�dd�dS)zBuild all source files.Nzall source files�all)�summary�method)�buildrrUrHrHrI�	build_allszBuilder.build_all�	filenamescCs�t|j�d}g}t|jj�}|D]N}t�t�|��}|�|j�s*t	�
td�|�qt�|�s8t	�
td�|�q||d�}|D]}|�
|�rR|dt|��}nq@|�tjt�}|�|�q|j|dtd�t|�d�dS)z>Only rebuild as much as needed for changes in the *filenames*.rozIfile %r given on command line is not under the source directory, ignoringz6file %r given on command line does not exist, ignoringN�specificz%%d source files given on command line)r�r�)r�r7�tupler=�
source_suffixr�normpathr��
startswithrurvr�isfile�endswithr�r�r$�appendr�)rGr��dirlen�to_write�suffixes�filename�suffixrHrHrI�build_specifics4
�

�
�
�zBuilder.build_specificcCsJ|��}t|t�r|�dg|�dSt|�}|j|td�t|�d�dS)z8Only rebuild what was changed or added since last build.�__all__z0targets for %d source files that are out of date)r�N)rf�
isinstancer�r�r�rr�)rG�to_buildrHrHrI�build_updates
�
�zBuilder.build_update�update�docnamesr�r�c
	Cs,|rt�ttd�|j�|�t���t|���}Wd�n1s%wYt	|�}tjttd��dd�|j
�|j|�D]}|�
|�qAt	|�|}|rZt�td�|�nt�td��|r�dd	lm}ttd
���+tt�|j|�d��}	t�|j
|	tj�Wd�n1s�wYWd�n1s�wYtj|j_ttd���
|j
��Wd�n1s�wYn|d
kr�|s�t�ttd���dStj|j_|r�|dgkr�t|�|j
j@}tr�|jjdkr�|j r�|j�!d�|_"nd|_"t#�|_$|�%|t&|�|�|�'�|j$��dS)zaMain build method.

        First updates the environment, and then calls :meth:`write`.
        zbuilding [%s]: Nz"looking for now-outdated files... T��nonlz%d foundz
none foundr)�ENV_PICKLE_FILENAMEzpickling environment�wbzchecking consistencyr�zno targets are out of date.r�ro�writeF)(rur�rrrAr�pending_warningsr��readr�r;�check_dependentsr5r?�sphinx.applicationr�r�openr�joinr:�pickle�dump�HIGHEST_PROTOCOLr�CONSISTENCY_CHECK�phase�check_consistency�	RESOLVING�
found_docsr+�parallel�allow_parallel�is_parallel_allowedrEr)rFr�r��finish)
rGr�r�r��updated_docnames�doccountr]�outdatedr��frHrHrIr�*sN
����
��
z
Builder.buildcCs�tjttd��dd�|j�|j|�|jjtk}|j�	|�\}}}|j
�d|j|||�D]
}|�t
|�|jj@�q-|s?|rJ|�|jj|jj@�|rbt�|jjd�|jjpXd}tjd|dd�t�td�t|�t|�t|��|D]}|j
�d|j|�|j�|�qtt||B�}|j
�d	|j|�tr�t|�d
kr�|jjdkr�|j�d�}	nd
}	|	r�|j||jjd�n|�|�|jj|jjvr�td|j�|jj���|j
�d|j�D]}
|
dur�|� |
�q�t|j_t|�S)z�(Re-)read all files new or changed since last update.

        Store all environment docnames in the canonical format (ie using SEP as
        a separator in place of os.path.sep).
        zupdating environment: Tr�zenv-get-outdatedr1z[%s] z %s added, %s changed, %s removed�
env-purge-doczenv-before-read-docs�ror�F��nproczroot file %s not foundzenv-updatedN)!rur�rrr;�
find_filesr=�
config_statusr�get_outdated_filesr<�emitr�r�r��
glob_toctreesrrr�config_status_extrar��	clear_docrsr+r5r�r��_read_parallel�_read_serial�root_doc�all_docsr�doc2path�extend)rG�updated�added�changed�removed�docs�reasonr]r��par_ok�retvalrHrHrIr�nsJ
�
�
�
�zBuilder.readcCsNt|td�dt|�|jj�D]}|j�d|j|�|j�|�|�	|�qdS)N�reading sources... �purpler�)
rrr�r5r�r<r�r;r�r)rGr�r]rHrHrIr��s��zBuilder._read_serialr�c	s�|D]}�j�d�j|��j�|�qdttdtf�fdd�}dttdtddf�fdd�}t|�}t||�}t	|t
d	�d
t|��jj
�D]	}|�|||�qGt�tt
d���|��dS)Nr�r�r6cs.�j�j_|D]}��|�qt��jtj�Sr�)r5r;rr��dumpsr�)r�r]rUrHrI�read_process�s
z,Builder._read_parallel.<locals>.read_process�otherenvcs t�|�}�j�||�j�dSr�)r��loadsr;�merge_info_fromr5)r�r�r;rUrHrI�merge�s
z%Builder._read_parallel.<locals>.merger�r��waiting for workers...)r<r�r;r�rr��bytesr(r*rrr�r5r��add_taskrur�rr�)	rGr�r�r]r�r��tasks�chunks�chunkrHrUrIr��s
�zBuilder._read_parallelc	Cs�|j�|�t�|jd�}t�|�r|j�|�t|j��,t�	||j
j	��t|j|j|j�
|��}Wd�n1s=wYWd�n1sLwYtt��t�|j�
|���|jj|<|jj��|jj��|�||�dS)z>Parse a file and add/update inventory entries for the doctree.z
docutils.confN)r;�prepare_settingsrr�r8r��note_dependencyr r�default_roler=rr5r��max�time�getmtimer��	temp_data�clear�ref_context�
write_doctree)rGr]�docutilsconfrirHrHrIr�s
���zBuilder.read_doccCs�d|_d|_d|j_d|j_d|j_t�|j|d�}t	t�
|��t|d��}t�
||tj�Wd�dS1s;wYdS)zWrite the doctree to a file.Nz.doctreer�)�reporter�transformer�settings�warning_streamr;�record_dependenciesrr�r:r%�dirnamer�r�r�r�)rGr]ri�doctree_filenamer�rHrHrIr�s"�zBuilder.write_doctree�build_docnamesr�cCs|dus	|dgkr
|jj}|dkrt|�t|�B}nt|�}t�td�d�t|���t|�D]}|jj	�
|t��D]
}||jjvrG|�|�q:q/|�|jj
�ttd���
|�|�Wd�n1sfwY|jr}|jt|�|jjdd�dS|�t|��dS)Nr�r�zdocnames to write: %sz, zpreparing documentsror�)r;r�r�ru�debugrr�rsr��files_to_rebuildrrr?r=r�r�prepare_writingrE�_write_parallelr5r��
_write_serial)rGrr�r�r�r]�
tocdocnamerHrHrIr��s*
���


�z
Builder.writecCs�t���7t|td�dt|�|jj�D]}tj|j_	|j
�||�}tj|j_	|�
||�|�||�qWd�dS1s>wYdS)Nr�r�)rr�rrr�r5r�rr�r�r;�get_and_resolve_doctree�WRITING�write_doc_serialized�	write_doc)rGr�r]rirHrHrIrs
�

�"�zBuilder._write_serialcsdttttjfddf�fdd�}|d|dd�}}tj�j_�j	�
|��}tj�j_��||���
||�t|�}t||�}tj�j_t|td�dt|��jj�D]'}g}	t|�D]\}
}�j	�
|��}��||�|	�||f�q^|�||	�qVt�ttd	���|��dS)
Nr�r6cs(tj�j_|D]
\}}��||�qdSr�)rrr5r�r)r�r]rirUrHrI�
write_process!s
�z.Builder._write_parallel.<locals>.write_processrror�r�r�)rrr�r�documentrr�r5r�r;rrrrr(r*rrr�r��	enumerater�r�rur�rr�)rGr�r�r �	firstnamerirrr�arg�ir]rHrUrIr s*$



�zBuilder._write_parallelcCr_)z?A place where you can add logic before :meth:`write_doc` is runr`)rGr�rHrHrIr?rhzBuilder.prepare_writingcCr_)z5Where you actually write something to the filesystem.r`�rGr]rirHrHrIrCrhzBuilder.write_doccCrT)zoHandle parts of write_doc that must be called in the main process
        if parallel build is active.
        NrHr&rHrHrIrGrWzBuilder.write_doc_serializedcCrT)zWFinish the building process.

        The default implementation does nothing.
        NrHrUrHrHrIr�M�zBuilder.finishcCrT)zQCleanup any resources.

        The default implementation does nothing.
        NrHrUrHrHrI�cleanupTr'zBuilder.cleanup�option�defaultcCsHzd|j|f}t|j|�WSty#d||f}t|j|�YSw)z�Return a builder specific option.

        This method allows customization of common builder settings by
        inserting the name of the current builder in the option key.
        If the key does not exist, use default as builder name.
        z%s_%s)rA�getattrr=�AttributeError)rGr)r*�optnamerHrHrI�get_builder_config[s	�zBuilder.get_builder_config)r5r/r6N)r6Nr�)Nr�)r�)@�__name__�
__module__�__qualname__�__doc__rAr@�epilogr2rr�NodeVisitor�__annotations__rLrMr��use_message_catalogr4rr��supported_remote_images�supported_data_uri_imagesrJrrNrrQrSrVr\rbrer
rrfrgrr|r
r!r�r�r�r�r�r�r�r�r�r��intr�rr!rr	r�rrrrrr�r(r.rHrHrHrIr03s\


	
	
!


	
 D@$


r0)Lr2r�r�osr�typingrrrrrrr	r
rrr
�docutilsr�docutils.nodesr�
sphinx.configr�sphinx.environmentrrr�!sphinx.environment.adapters.assetr�
sphinx.errorsr�
sphinx.eventsr�	sphinx.ior�
sphinx.localer�sphinx.utilrrrrr�sphinx.util.build_phaser�sphinx.util.consoler�sphinx.util.docutilsr �sphinx.util.i18nr!r"r#�sphinx.util.osutilr$r%r&r'�sphinx.util.parallelr(r)r*r+�sphinx.util.tagsr,�sphinxr-r.�multiprocessing�ImportErrorr�r/�	getLoggerr/rur0rHrHrHrI�<module>sB
4�