
    -Ph>                    >   d Z ddlmZ ddlZddlZddlZddl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mZmZ ddlmZ ddlmZ ddlmZ ddlmZm Z 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dl+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z: ddl9m;Z; erBddl<m=Z=m>Z>m?Z? ddl@mAZA ddlmBZBmCZC ddlDmEZE ddlFmGZG ddlHmIZI ddlmJZJ dd lKmLZL dd!l-mMZM dd"lNmOZO  e jP        eQ          ZR G d# d$          ZS G d% d&          ZTdS )'z$Builder superclass for all builders.    )annotationsN)nullcontext)Path)TYPE_CHECKINGfinal)nodes)DependencyList)bold)CONFIG_CHANGED_REASON	CONFIG_OK_CurrentDocument)ImageAdapter)SphinxError)__)get_filetypeloggingrst)import_object)_StrPathProperty)
BuildPhase)progress_messagestatus_iterator)sphinx_domains)CatalogRepositorydocname_to_domain)	ensuredirrelative_urirelpath)ParallelTasksSerialTasksmake_chunksparallel_available)
directives)roles)IterableSequenceSet)NullTranslations)AnyLiteral)Node)Sphinx)Config)BuildEnvironment)EventManager)CatalogInfo)Tagsc                     e Zd ZU dZdZded<   dZded<   dZded<   ded<   d	Zd
Z	d
Z
ded<   dZg Zded<   d
Zded<   d
Zded<    e            Z e            Z e            Z e            ZdadZedbd            ZdcdZdddZded Zded!Zdfdgd&Zdfdhd)Zdid+Zdjd,Zdkd/Zdld3Z ded4Z!dmd7Z"ded8Z#e$ded9            Z%e$dnd<            Z&e$ded=            Z'e$	 	 dodpdD            Z(e$djdE            Z)dqdFZ*drdIZ+e$ddJdsdL            Z,e$ddJdtdN            Z-e$	 dudvdR            Z.dwdTZ/dxdVZ0dydWZ1dwdXZ2dedYZ3dzdZZ4dzd[Z5ded\Z6ded]Z7d{d`Z8d"S )|Builderz,Builds target formats from the reST sources. strnameformatepilogtype[nodes.NodeVisitor]default_translator_classnoneFboolallow_parallelT	list[str]supported_image_typessupported_remote_imagessupported_data_uri_imagesappr,   envr.   returnNonec                   |j         | _         |j        | _        |j        | _        |j        | _        t	          | j                   || _        || _        | j                            | j        | j	                   |j
        | _
        |j        | _        |j        | _        | j                            | j                   | j                            | j                   | j                            d| j                    | j                            d| j                    i | _        d| _        d| _        d| _        d | _        d S )Nformat_builder_r4   F)srcdirconfdiroutdir
doctreedirr   rB   rC   set_versioning_methodversioning_methodversioning_compareeventsconfigtagsaddr7   r6   imagesimagedirimgpathparallel_okfinish_tasks)selfrB   rC   s      X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/builders/__init__.py__init__zBuilder.__init__n   s   j{j.$/"""%(&&t'=t?VWWW$'J!j(		dk"""	di   	---...	,,,--- ') !!%    NullTranslations | Nonec                    | j         j        S N)rB   
translatorrY   s    rZ   _translatorzBuilder._translator   s    x""r\   argsr)   c                @    | j         j                            |           S )zReturn a class of translator.)rC   	_registryget_translator_classrY   rc   s     rZ   rf   zBuilder.get_translator_class   s    x!66t<<<r\   nodes.NodeVisitorc                2     | j         j        j        | g|R  S )zReturn 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.
        )rC   re   create_translatorrg   s     rZ   rj   zBuilder.create_translator   s$     4tx!3D@4@@@@r\   c                    dS )zoLoad necessary templates and perform initialization.  The default
        implementation does nothing.
        N ra   s    rZ   initzBuilder.init   	     	r\   c                    | j         j        r,t          | j         j        d          } |            | _        dS ddlm}  |            | _        dS )z&Return the template bridge configured.ztemplate_bridge setting)sourcer   )BuiltinTemplateLoaderN)rQ   template_bridger   	templatessphinx.jinja2gluerq   )rY   template_bridge_clsrq   s      rZ   create_template_bridgezBuilder.create_template_bridge   sk    ;& 		5"/+0# # # 1022DNNN??????2244DNNNr\   Ndocnametyp
str | Nonec                    t           )zReturn the target URI for a document name.

        *typ* can be used to qualify the link characteristic for individual
        builders.
        NotImplementedError)rY   rw   rx   s      rZ   get_target_urizBuilder.get_target_uri   s
     "!r\   from_toc                p    t          |                     |          |                     ||                    S )zReturn a relative URI between two source filenames.

        :raises: :exc:`!NoUri` if there's no way to return a sensible URI.
        )r   r}   )rY   r~   r   rx   s       rZ   get_relative_urizBuilder.get_relative_uri   s:    
 &&C((
 
 	
r\   str | Iterable[str]c                    t           )aD  Return 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{   ra   s    rZ   get_outdated_docszBuilder.get_outdated_docs   s
     "!r\   c                    g S )z;Return list of paths for assets (ex. templates, CSS, etc.).rl   ra   s    rZ   get_asset_pathszBuilder.get_asset_paths   s    	r\   doctreer+   c                   t          | j                  }|                    t          j                  D ]}d|d         v rd|d         vr| j        D ]"}|d                             |d          }|r n#t          |d                   }|                    |d                   }|r2t          
                    t          d          | j        |||           n0t          
                    t          d          | j        ||           ||d<   n|d         }|| j        j        vr| j        j        |         d	         | j        |<   dS )
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   )r   rC   findallr   imager?   getsortedget_original_image_uriloggerwarningr   r6   rT   )rY   r   rT   nodeimgtype	candidate	mimetypes	image_uris           rZ   post_process_imageszBuilder.post_process_images   s   dh''OOEK00 "	C "	CDd<((($|,,,#9  G $\ 2 6 6w E EI   !'tL'9 : :I & = =d5k J JI  STT I%%%) '     NOO I%%)	 '    'U K	//%)X_Y%?%BDK	""E"	C "	Cr\   catalogsset[CatalogInfo]messagec                r   | j         j        sd S | j        fdd}t                              t          t          d                    |z              t          |t          d	          d
t          |          | j	        j
        |          D ],}|                    | j         j        | j         j                   -d S )Ncatr0   rI   r   rD   r5   c                j    t          t          | j        |                                                    S r_   )r   r   mo_pathas_posix)r   rI   s     rZ   cat2relpathz-Builder.compile_catalogs.<locals>.cat2relpath   s(    V4455>>@@@r\   zbuilding [mo]: writing output... 	darkgreen)stringify_func)r   r0   rI   r   rD   r5   )rQ   gettext_auto_buildrI   r   infor
   r   r   lenrB   	verbositywrite_molanguage gettext_allow_fuzzy_translations)rY   r   r   r   catalogs        rZ   compile_catalogszBuilder.compile_catalogs   s    {- 	F9= 	A 	A 	A 	A 	A 	D-..//'9:::&#$$MMH&
 
 
 
	 
	G $dk&R   
	 
	r\   c                "   t          | j        | j        j        | j        j        | j        j                  }t          d          t          t          |j	                            z  }| 
                    t          |j	                  |           d S )Nzall of %d po files)r   rI   rQ   locale_dirsr   source_encodingr   r   listr   r   set)rY   repor   s      rZ   compile_all_catalogszBuilder.compile_all_catalogs  s{     KK#K K'	
 
 )**Sdm1D1D-E-EEc$-00':::::r\   specified_filesIterable[Path]c                  	 | j         | j        j        		fd|D             }t                      }t	          | j        | j        j        | j        j        | j        j                  }|j	        D ]4}|j
        |v r)|                                r|                    |           5t          d          t          |          z  }|                     ||           d S )Nc                f    h | ]-}                     |          xrt                    nd .S r_   )path2docr   ).0filerw   rC   gettext_compacts     rZ   	<setcomp>z4Builder.compile_specific_catalogs.<locals>.<setcomp>  sU     
 
 
<<---
;BLg777
 
 
r\   z*targets for %d po files that are specified)rC   rQ   r   r   r   rI   r   r   r   r   domainis_outdatedrS   r   r   r   )
rY   r   domainsr   r   r   r   rw   rC   r   s
          @@@rZ   compile_specific_catalogsz!Builder.compile_specific_catalogs  s    h+5
 
 
 
 
 
'
 
 

 55 KK#K K'	
 
 } 	& 	&G~((W-@-@-B-B(W%%%ABBS]]Rh00000r\   c                    t          | j        | j        j        | j        j        | j        j                  }d |j        D             }t          d          t          |          z  }| 	                    ||           d S )Nc                :    h | ]}|                                 |S rl   )r   )r   cs     rZ   r   z2Builder.compile_update_catalogs.<locals>.<setcomp>4  s%    @@@!@A@@@r\   z,targets for %d po files that are out of date)
r   rI   rQ   r   r   r   r   r   r   r   )rY   r   r   r   s       rZ   compile_update_catalogszBuilder.compile_update_catalogs-  s{     KK#K K'	
 
 A@t}@@@CDDs8}}Th00000r\   c                x    |                                   |                     dt          d          d           dS )zBuild all source files.Nzall source filesallsummarymethod)r   buildr   ra   s    rZ   	build_allzBuilder.build_all:  s=     	!!###

4$6!7!7
FFFFFr\   	filenamesSequence[Path]c                t   g }d |D             }|D ]}|                                 s)t                              t          d          |           ?|                    | j                  s)t                              t          d          |           | j                            |          }|s)t                              t          d          |           |                    |           | 	                    |           | 
                    |t          d          t          |          z  d           dS )	z>Only rebuild as much as needed for changes in the *filenames*.c                P    g | ]#}t          |                                          $S rl   )r   resolve)r   filenames     rZ   
<listcomp>z*Builder.build_specific.<locals>.<listcomp>F  s*    HHH(T(^^++--HHHr\   z.file %r given on command line does not exist, zIfile %r given on command line is not under the source directory, ignoringz?file %r given on command line is not a valid document, ignoringz%%d source files given on command linespecificr   N)is_filer   r   r   is_relative_torI   rC   r   appendr   r   r   )rY   r   docnamesr   rw   s        rZ   build_specificzBuilder.build_specificA  sl    !HHiHHH	! 	% 	%H##%% GHH(   **4;77 5     h''11G -     OOG$$$$&&y111

>??#h--O 	 	
 	
 	
 	
 	
r\   c                >   |                                   |                                 }t          |t                    r|                     dg|d           dS t          |          }|                     |t          d          t          |          z  d           dS )z8Only rebuild what was changed or added since last build.__all__updater   z0targets for %d source files that are out of dateN)r   r   
isinstancer5   r   r   r   r   )rY   to_builds     rZ   build_updatezBuilder.build_updatem  s     	$$&&&))++h$$ 		JJ	{HXJFFFFF8}}HJJMNNh-- 	      r\   r   r   Iterable[str] | Noner   r   $Literal['all', 'specific', 'update']c                   |r=t                               t          t          d                    |z   | j                   | j        j        rt                      nt          j	                    5  t          |                                           }ddd           n# 1 swxY w Y   t          |          }t                               t          t          d                    d           |                    | j                            | j        |                     t          |          |z
  }|r)t                               t          d          |           n't                               t          d                     |rdd	lm} t%          t          d
                    5  t'          | j        |z  d          5 }t+          j        | j        |t*          j                   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t0          j        | j        _        t%          t          d                    5  | j                                         ddd           n# 1 swxY w Y   n<|dk    r6|s4t                               t          t          d                               t0          j        | j        _        |r#|dgk    rt          |          | j        j        z  }t<          r7| j        j        dk    r'| j         r | j        !                    d          | _"        nd| _"        tG                      | _$        | %                    |||           | &                                 | j$        '                                 dS )zMain build method, usually called by a specific ``build_*`` method.

        First updates the environment, and then calls
        :meth:`!write`.
        zbuilding [%s]: Nz"looking for now-outdated files... Tnonlz%d foundz
none foundr   )ENV_PICKLE_FILENAMEzpickling environmentwbzchecking consistencyr   zno targets are out of date.r   r   writeF)(r   r   r
   r   r6   rB   _exception_on_warningr   r   pending_warningsr   readr   r   rC   check_dependentssphinx.applicationr   r   openrL   pickledumpHIGHEST_PROTOCOLr   CONSISTENCY_CHECKphasecheck_consistency	RESOLVING
found_docsr"   parallelr=   is_parallel_allowedrW   r    rX   r   finishjoin)	rY   r   r   r   updated_docnamesdoccountoutdatedr   fs	            rZ   r   zBuilder.build~  s>     	JKKR 12233g=tyIII
 x-,KMMM)++	0 	0
  #499;;//	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 '((D@AABBNNN 9 9$(DT U UVVV'((83 	*KK:1111KK<(())) 	E>>>>>> !$:!;!;<<B BT_'::DAABEFDHa)@AAA	B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B (9DHN!"%;"<"<== - -**,,,- - - - - - - - - - - - - - - !!(!D$A!B!BCCDDD#-
  	;YK//8}}tx'::H  	%$("3a"7"7D<O"7#x;;GDDD$D (MM 	

8-v666 	 	     sZ   -"BB"B&H?&G1%H1G5	5H8G5	9HHHI++I/2I/c                   t                               t          t          d                    d           | j                            | j        |            | j        j        t          k    }| j        	                    |          \  }}}| j
                            d| j        |||          D ]1}|                    t          |          | j        j        z             2|s|r,|                    | j        j        | j        j        z             |rKt!          j        | j        j        d          | j        j        pdz   }t                               d|d           t                               t          d          t'          |          t'          |          t'          |                     |D ]=}| j
                            d| j        |           | j                            |           >t+          ||z            }| j
                            d	| j        |           t,          r+| j        j        d
k    r| j                            d          }	nd}	|	r"|                     || j        j                   n|                     |           | j        j        | j        j        vrlddlm}
 ddl m! | j        "                    | j        j                  }|#                                |
D ]C}tI          j%         |                    s!t          d          }tM          |||fz            | j        j'        D ]C}tI          j%         |                    s!t          d          }tM          |||fz            t          | j        j(                  dhk    rStS          fd| j        j(        D                       s-t          d          }tM          ||| j        j(        fz            t          d          }tM          ||z            | j
                            d| j                  D ]}||*                    |           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).
        zupdating environment: Tr   zenv-get-outdatedr4   z[%s] z %s added, %s changed, %s removedenv-purge-doczenv-before-read-docsr   r   Fnprocr   )EXCLUDE_PATHS)_translate_patternzSphinx is unable to load the master document (%s) because it matches a built-in exclude pattern %r. Please move your master document to a different location.zSphinx is unable to load the master document (%s) because it matches an exclude pattern specified in conf.py, %r. Please remove this pattern from conf.py.z**c              3  T   K   | ]"}t          j         |                    V  #d S r_   )rematch)r   patr  master_doc_canons     rZ   	<genexpr>zBuilder.read.<locals>.<genexpr>"  sX       G G ++C002BCCG G G G G Gr\   zSphinx is unable to load the master document (%s) because it is not included in the custom include_patterns = %r. Ensure that a pattern in include_patterns matches the master document.zSphinx is unable to load the master document (%s). The master document must be within the source directory or a subdirectory of it.zenv-updated)+r   r   r
   r   rC   
find_filesrQ   config_statusr   get_outdated_filesrP   emitr   r   r   glob_toctreesr   r   config_status_extrar   	clear_docr   r"   rB   r   r   _read_parallel_read_serial
master_docall_docssphinx.projectr  sphinx.util.matchingr  doc2pathr   r	  r
  r   exclude_patternsinclude_patternsanyextend)rY   updatedaddedchangedremoveddocsreasonrw   r   par_okr  master_doc_pathr  msgretvalr  r  s                  @@rZ   r   zBuilder.read  s    	D45566TBBBDK...((I5"&("="=g"F"Fw K$$%'
 
 	< 	<D NN3t99tx'::;;;;  	IG 	INN481DH4GGHHH 	4*.tx/ErJJ,2F KKdK333122JJLLLL		
 	
 	
  	( 	(GK_dh@@@Hw'''' %'/**/8DDD  	$("3a"7"7X11&99FFF 	(0ABBBBh''';!):::444444??????"h//0FGGO.7799$ @ @x 2 23 7 79IJJ P 
 "##(>">???{3 	@ 	@x 2 23 7 79IJJ ?  "##(>">???4;/00TF::3 G G G G G;7G G G D D: '  "#$+:V(W"WXXX+ C
 cO3444k&&}dh?? 	( 	(F!''' "+hr\   c                   t          |t          d          dt          |          | j        j                  D ]R}| j                            d| j        |           | j                            |           | 	                    |           Sd S )Nreading sources... purpler  )
r   r   r   rB   r   rP   r  rC   r  read_doc)rY   r   rw   s      rZ   r  zBuilder._read_serial=  s    &$%%MMH
 
 
	# 
	#G K_dh@@@Hw'''MM'""""
	# 
	#r\   r  intc                   	 t          ||          }t          |t          d          dt          |           j        j                  	|D ]=} j                            d j        |            j        	                    |           >d fd}d	 fd}t          |          }|D ]}|                    |||           |                                 t                              d           d S )Nr+  r,  r  r$  r>   rD   bytesc                    j         j        _         | D ]}                    |d           t          j        j        t          j                  S )NF_cache)rB   rC   r-  r   dumpsr   )r$  rw   rY   s     rZ   read_processz,Builder._read_parallel.<locals>.read_processX  sM    8DHL 5 5ge4444<&*ABBBr\   otherenvrE   c                    t          j        |          }j                            | |j                   t                     d S r_   )r   loadsrC   merge_info_fromrB   next)r$  r6  rC   progressrY   s      rZ   mergez%Builder._read_parallel.<locals>.merge_  s=    ,x((CH$$T3999NNNNNr\   r4   )r$  r>   rD   r0  )r$  r>   r6  r0  rD   rE   )r!   r   r   r   rB   r   rP   r  rC   r  r   add_taskr   r   r   )
rY   r   r  chunksrw   r5  r<  taskschunkr;  s
   `        @rZ   r  zBuilder._read_parallelJ  s)   Xu-- #B,--xVdhFX
 

   	( 	(GK_dh@@@Hw''''	C 	C 	C 	C 	C 	C	 	 	 	 	 	 	 e$$ 	7 	7ENN<6666 	

Br\   r2  r3  c                  | j         }|                    |           | j        dz  }|                                r|                    |           t          |                    |                    }t          | j        j	        j
        |          }| j         j                            | j        |          }|j        | j         j        _        t!                      |j        _        t'          |          5  t)          j        || j	        j                  5  t-          |          }t/          j        d|           |                    |           |                                 |j        }	ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t9          j                    dz  |j        |<   t?                      |_        |j         !                                 | "                    ||	|           dS )z>Parse a file and add/update inventory entries for the doctree.zdocutils.confsphinx)source_pathNi  r2  )#rC   prepare_settingsrJ   r   note_dependencyr5   r  r   rB   rQ   source_suffixre   get_publisherparsercurrent_document_parserr	   settingsrecord_dependenciesr   r   default_role_UnicodeDecodeErrorHandlercodecsregister_error
set_sourcepublishdocumenttimetime_nsr  r   ref_contextclearwrite_doctree)
rY   rw   r3  rC   docutils_confr   filetype	publishererror_handlerr   s
             rZ   r-  zBuilder.read_docm  sE    hW%%% 6  "" 	/...s||G,,-- =xHHH&44TXxHH	,5,<!) 2@1A1A	.3
	) 
	)Wdk&>??
	) 
	)
 7w??M!(M:::  X 666(G
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) !%% 7W  0117GF;;;;;s7   3 FAE5)F5E9	9F<E9	=FFFnodes.documentc                  d|_         d|_        |j                                        |_        d|j        _        d|j        _        d|j        _        | j        | dz  }|j        	                    dd           t          |d          5 }t          j        ||t          j                   ddd           n# 1 swxY w Y   |r|| j        j        |<   dS dS )z@Write the doctree to a file, to be used as a cache by re-builds.Nz.doctreeT)parentsexist_okr   )reportertransformerrK  copywarning_streamrC   rL  rL   parentmkdirr   r   r   r   _write_doc_doctree_cache)rY   rw   r   r3  doctree_filenamer  s         rZ   rX  zBuilder.write_doctree  s&     " #+0022*.'#/3,?-A-A-AA%%dT%BBB"D)) 	=QKF$;<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=  	A9@DH-g666	A 	As   
!B77B;>B;build_docnamesr   Iterable[str]c                   | j         | j                            d|            ||dgk    rj        }|dk    r t	          |          t	          |          z  }nt	          |          }|rIt
                              t          d          d                    t          |                               n't
                              t          d                     |fd|D             z  }t          t          j                                                            _        t          t          d	                    5  |                     |           ddd           n# 1 swxY w Y   t          t          d
          d          5  |                                  ddd           n# 1 swxY w Y   |r|                     |           dS dS )z$Write builder specific output files.zwrite-startedNr   r   zdocnames to write: %sz, zno docnames to write!c                b    h | ]+}j                             |d           D ]}|j        v |,S )rl   )files_to_rebuildr   r   )r   rw   toc_docnamerC   s      rZ   r   z Builder.write.<locals>.<setcomp>  sZ     
 
 
"377DD
 
 cn,,  -,,,r\   zpreparing documentszcopying assetsFr   )rC   rP   r  r   r   r   debugr   r   r   dicttoctree_includesitemsr   prepare_writingcopy_assetswrite_documents)rY   ri  r   r   r   rC   s        @rZ   r   zBuilder.write  sY    h 	$///!^	{%B%B ^NX>**S1A-B-BBHH>**H 	6LL344diix@P@P6Q6QRRRRLL344555 	 
 
 
 
#
 
 
 	
  $F3+?+E+E+G+G$H$HIIb!67788 	+ 	+  ***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ b!122??? 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	  	+  *****	+ 	+s$    E""E&)E&F,,F03F0Set[str]c                    t          |          }| j        r&|                     || j        j        dz
             dS |                     |           dS )zWrite all documents in *docnames*.

        This method can be overridden if a builder does not create
        output files for each document.
        r   r  N)r   rW   _write_parallelrB   r   _write_serial)rY   r   sorted_docnamess      rZ   ru  zBuilder.write_documents  sa     !** 	0   8IA8M NNNNN/////r\   Sequence[str]c           	        | j         j        rt                      nt          j                    5  t          |t          d          dt          |          | j         j                  D ]u}t          j
        | j         _        | j                            ||           }t          j        | j         _        |                     ||           |                     ||           v	 d d d            d S # 1 swxY w Y   d S )Nr   r   )rB   r   r   r   r   r   r   r   r   r   r   r   rC   get_and_resolve_doctreeWRITINGwrite_doc_serialized	write_doc)rY   r   rw   r   s       rZ   ry  zBuilder._write_serial  s-    x-,KMMM)++	1 	1
 +'((H"  1 1 ",!5(::7DII!+!3))'7;;;w00001	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   B.C**C.1C.c                6    d fd}|d         |dd          }}t           j         j        _         j                            |           }t           j         j        _                             ||                                ||           t          |          }t          ||          }t          |t          d          d	t          |           j        j                  dfd}t           j         j        _        |D ]h}	g }
|	D ]J} j                            |           }                     ||           |
                    ||f           K|                    ||
|           i|                                 t$                              d           d S )Nr$   list[tuple[str, nodes.document]]rD   rE   c                p    t           j        j        _        | D ]\  }}                    ||           d S r_   )r   r~  rB   r   r  )r$  rw   r   rY   s      rZ   write_processz.Builder._write_parallel.<locals>.write_process  sD    '/DHN$( 1 1 w00001 1r\   r   r   r   r   rc   resultc                &    t                     d S r_   )r:  )rc   r  r;  s     rZ   on_chunk_donez.Builder._write_parallel.<locals>.on_chunk_done  s    NNNNNr\   r4   )r$  r  rD   rE   )rc   r  r  rE   rD   rE   )r   r   rB   r   rC   r}  r~  r  r  r   r!   r   r   r   r   r   r=  r   r   r   )rY   r   r  r  	firstnamer   r?  r>  r  r@  argrw   r;  s   `           @rZ   rx  zBuilder._write_parallel  s   	1 	1 	1 	1 	1 	1 'qk8ABB<8	#-(229dCC#+!!)W555y'***e$$Xu-- ##$$KKH
 
	 	 	 	 	 	 $- 	> 	>EC  / /(::7DII))'7;;;

GW-....NN=#}==== 	

Br\   c                    dS )z?A place where you can add logic before :meth:`write_doc` is runNrl   )rY   r   s     rZ   rs  zBuilder.prepare_writing-      r\   c                    dS )zBWhere assets (images, static files, etc) are copied before writingNrl   ra   s    rZ   rt  zBuilder.copy_assets1  r  r\   c                    t           )aY  Write the output file for the document

        :param docname: the :term:`docname <document name>`.
        :param doctree: defines the content to be written.

        The output filename must be determined within this method,
        typically by calling :meth:`~.Builder.get_target_uri`
        or :meth:`~.Builder.get_relative_uri`.
        r{   rY   rw   r   s      rZ   r  zBuilder.write_doc5  s
     "!r\   c                    dS )zoHandle parts of write_doc that must be called in the main process
        if parallel build is active.
        Nrl   r  s      rZ   r  zBuilder.write_doc_serializedA  rn   r\   c                    dS )zWFinish the building process.

        The default implementation does nothing.
        Nrl   ra   s    rZ   r   zBuilder.finishG  	    
 	r\   c                    dS )zQCleanup any resources.

        The default implementation does nothing.
        Nrl   ra   s    rZ   cleanupzBuilder.cleanupN  r  r\   optiondefaultc                    	 | j          d| }t          | j        |          S # t          $ r | d| }t          | j        |          cY S w xY w)zReturn 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.
        _)r6   getattrrQ   AttributeError)rY   r  r  optnames       rZ   get_builder_configzBuilder.get_builder_configU  st    	1--V--G4;000 	1 	1 	1 ++6++G4;00000	1s    # &AA)rB   r,   rC   r.   rD   rE   )rD   r]   )rc   r)   rD   r9   )rc   r)   rD   rh   )rD   rE   r_   )rw   r5   rx   ry   rD   r5   )r~   r5   r   r5   rx   ry   rD   r5   )rD   r   )rD   r>   )r   r+   rD   rE   )r   r   r   r5   rD   rE   )r   r   rD   rE   )r   r   rD   rE   )Nr   )r   r   r   ry   r   r   rD   rE   )r   r>   rD   rE   )r   r>   r  r.  rD   rE   )rw   r5   r3  r<   rD   rE   )rw   r5   r   r]  r3  r<   rD   rE   )r   )ri  r   r   rj  r   r   rD   rE   )r   rv  rD   rE   )r   r{  rD   rE   )r   r{  r  r.  rD   rE   )rw   r5   r   r]  rD   rE   )r  r5   r  r5   rD   r)   )9__name__
__module____qualname____doc__r6   __annotations__r7   r8   rN   rO   r=   use_message_catalogr?   r@   rA   r   rI   rJ   rK   rL   r[   propertyrb   rf   rj   rm   rv   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r-  rX  r   ru  ry  rx  rs  rt  r  r  r   r  r  rl   r\   rZ   r3   r3   D   s{        66 DNNNN F F 6555 N     (*))))$)))))&+++++F  GF!!##J& & & &: # # # X#= = = =A A A A   5 5 5 5" " " " "
 
 
 
 
" " " "   %C %C %C %CR   (; ; ; ;1 1 1 1.	1 	1 	1 	1 G G G UG )
 )
 )
 U)
V    U   #7?	M! M! M! M! UM!^ l  l  l  Ul \# # # #! ! ! !F 7; $< $< $< $< $< U$<L  A A A A A UA< 
 8@	++ ++ ++ ++ U++Z0 0 0 01 1 1 1&) ) ) )V      
" 
" 
" 
"         1 1 1 1 1 1r\   r3   c                  "    e Zd ZdZddZdd
ZdS )rN  z8Custom error handler for open() that warns and replaces.rw   r5   rD   rE   c                   || _         d S r_   )rw   )rY   rw   s     rZ   r[   z#_UnicodeDecodeErrorHandler.__init__i  s    r\   errorUnicodeDecodeErrortuple[str, int]c                   |j                             dd|j                  }|j                             d|j                  }|dk    rt	          |j                   }|j                             dd|j                  dz   }t                              t          d          |j         |dz   |j                 dz   |j         |j        |j	                 z   dz   |j         |j	        |         z   | j
        |f           d	|j	        fS )
N   
r   r   z5undecodable source characters, replacing with "?": %rs   >>>s   <<<r   r   )objectrfindstartfindr   countr   r   r   endrw   )rY   r  
line_startline_endline_nums        rZ   __call__z#_UnicodeDecodeErrorHandler.__call__l  s   \''q%+>>
<$$UEK88r>>5<((H<%%eQ<<q@FGGZ!^ek9:,u{UY678  ,uy834	5 lH- 	 
	
 
	
 
	
 EI~r\   N)rw   r5   rD   rE   )r  r  rD   r  )r  r  r  r  r[   r  rl   r\   rZ   rN  rN  f  sB        BB        r\   rN  )Ur  
__future__r   rO  r   r	  rT  
contextlibr   pathlibr   typingr   r   docutilsr   docutils.utilsr	   sphinx._cli.util.colourr
   sphinx.environmentr   r   r   !sphinx.environment.adapters.assetr   sphinx.errorsr   sphinx.localer   sphinx.utilr   r   r   sphinx.util._importerr   sphinx.util._pathlibr   sphinx.util.build_phaser   sphinx.util.displayr   r   sphinx.util.docutilsr   sphinx.util.i18nr   r   sphinx.util.osutilr   r   r   sphinx.util.parallelr   r    r!   r"   rB  r#   r$   collections.abcr%   r&   r'   gettextr(   r)   r*   docutils.nodesr+   r   r,   sphinx.configr-   r.   sphinx.eventsr/   r0   sphinx.util.tagsr1   	getLoggerr  r   r3   rN  rl   r\   rZ   <module>r     s   * * " " " " " "   				  " " " " " "       ' ' ' ' ' ' ' '       ) ) ) ) ) ) ( ( ( ( ( (         
 ; : : : : : % % % % % %               
 0 / / / / / 1 1 1 1 1 1 . . . . . . A A A A A A A A / / / / / / A A A A A A A A ? ? ? ? ? ? ? ? ? ?                        &7777777777((((((##############))))))$$$$$$      +*****,,,,,,%%%%%% 
	8	$	$_1 _1 _1 _1 _1 _1 _1 _1D         r\   