
    }cv%                        d Z ddlZddlZddlmZ ddlmZmZmZ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 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 ddlmZ ddl m!Z!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. ddl/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5  e$j6        e7          Z8ej        9                    edd          Z: G d de          Z;dedee	e<e<e<e<e<e<e<f                  fdZ=dedee<ef         fdZ>dS ) zTexinfo builder.    N)path)AnyDictIterableListTupleUnion)nodes)OptionParser)
FileOutput)Node)addnodespackage_dir)Sphinx)Builder)Config)ImageAdapter)NoUri)___)loggingprogress_messagestatus_iterator)	darkgreen)new_document)copy_asset_file)inline_all_toctrees)SEP	ensuredirmake_filename_from_project)TexinfoTranslatorTexinfoWriter	templatestexinfoc            	       4   e Zd ZdZdZdZ ed          Zej        dk    re ed          z  Zg dZ	e
Zdd	Zdeeee         f         fd
ZddededefdZddedededefdZddZdeddfdZdededee         dej        fdZddZdeddfdZddZdS )TexinfoBuilderz=
    Builds Texinfo output to create Info documentation.
    r$   z$The Texinfo files are in %(outdir)s.posixzl
Run 'make' in that directory to run these through makeinfo
(use 'make info' here to do that automatically).)z	image/pngz
image/jpegz	image/gifreturnNc                 "    g | _         g | _        d S N)docnamesdocument_dataselfs    7lib/python3.11/site-packages/sphinx/builders/texinfo.pyinitzTexinfoBuilder.init0   s    ')SU    c                     dS )Nzall documents r-   s    r/   get_outdated_docsz TexinfoBuilder.get_outdated_docs4   s    r1   docnametypc                 >    || j         vrt          ||          d|z   S )N%)r+   r   )r.   r5   r6   s      r/   get_target_urizTexinfoBuilder.get_target_uri7   s+    $-' 	!%%%= r1   from_toc                 .    |                      ||          S r*   )r9   )r.   r:   r;   r6   s       r/   get_relative_urizTexinfoBuilder.get_relative_uri=   s    ""2s+++r1   c                    d | j         j        D             }|s)t                              t	          d                     d S g | _        |D ]}|d         }|| j        j        vr)t                              t	          d          |           A| j        	                    |           |
                    t          dz             r
|d d         }| j        	                    ||d         f           d S )Nc                 ,    g | ]}t          |          S r3   )list).0xs     r/   
<listcomp>z5TexinfoBuilder.init_document_data.<locals>.<listcomp>B   s    $T$T$TT!WW$T$T$Tr1   zGno "texinfo_documents" config value found; no documents will be writtenr   z?"texinfo_documents" config value references unknown document %sindex   )configtexinfo_documentsloggerwarningr   titlesenvall_docsr,   appendendswithr   )r.   preliminary_document_dataentryr5   s       r/   init_document_dataz!TexinfoBuilder.init_document_dataA   s   $T$Tdk6S$T$T$T!( 	NN2 0 1 1 2 2 2F-/. 		4 		4EAhGdh// r #0  1  129; ; ;%%e,,,g.. '!#2#,Kq23333		4 		4r1   ignoredc                    |                                   | j        D ];}|d d         \  }}}}|dz  }dx}x}}	t          |          dk    r|dd         \  }}}	d}
t          |          dk    r|d         }
t          t	          j        | j        |          d          }t          t          d	          |z            5  | j	        j
        pg }|                     ||
|
          }d d d            n# 1 swxY w Y   t          t          d                    5  |                     |           t          |           }t          j                    5  t          j        dt"                     t%          | j        j        |fd                                          }d d d            n# 1 swxY w Y   ||_        ||_        |d d         dz   |_        | j	        j        |_        |pd|_        |	pd|_        |pd|_        ||_        ||_        |                    ||           |                     |d d                    d d d            n# 1 swxY w Y   =d S )N   z.texi       Fzutf-8)destination_pathencodingzprocessing %s)
appendiceswritingignore)categoryT)defaults
componentsread_config_filesrE   z.info) rR   r,   lenr   r   joinoutdirr   r   rG   texinfo_appendicesassemble_doctreepost_process_imagesr"   warningscatch_warningsfilterwarningsDeprecationWarningr   rL   settingsget_default_valuesauthortitletexinfo_filenametexinfo_elementstexinfo_dir_entrytexinfo_dir_categorytexinfo_dir_descriptionr5   writecopy_image_files)r.   rS   rQ   r5   
targetnamero   rn   direntrydescriptionr^   toctree_onlydestinationr[   doctree	docwriterrl   s                   r/   ru   zTexinfoBuilder.writeT   sb   !!!' %	7 %	7E16rr.GZ'!J022H2{X5zzA~ =27!*/+x L5zzA~ ($Qx$!%4;
!C!C " " "K ""_"5"5
"BCC ^ ^![;Ar
//R\/]]^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ""Y--00 7 7((111)$//	,.. E E+H?QRRRR %1!%!2$-<*.%0 %0 %0 1C0B0D0D 	E E E E E E E E E E E E E E E #)!&,6ssOg,E),0K,H)-5^*08B-3>3D"0#* #+ 555%%j"o666+7 7 7 7 7 7 7 7 7 7 7 7 7 7 7!%	7 %	7sJ   ?'C22C6	9C6	8IAF(I(F,,I/F,0BII	I		indexfilerz   r[   c           	         t          |g|z             | _        t                              t	          |          dz   d           | j                            |          }||d<   |rht          d          }t          j	                    }|t          j
        dd          z  }||z  }|                    t          j                  D ]}||z  }|}t          | | j        ||t          |g          }||d<   |D ]6}	| j                            |	          }
|	|
d<   |                    |
           7t                              d           t                              t!          d                     | j                            |||            |                    t          j                  D ]}|d	         }	|d
         }t          j        ||          g}| j        D ]\  }}|	                    |          r|                    t          j        t/          d                               |                    t          j        ||                     |                    t          j        d                      n	 |                    |           |S )N Tnonlr5   z<texinfo output>z<Set title in conf.py>rV   zresolving references...
refdocnamerefsectnamez (in ))setr+   rI   infor   rL   get_doctreer   r
   sectionro   findallr   toctreer   rN   r   resolve_referencespending_xrefemphasisrK   
startswithTextr   replace_self)r.   r~   rz   r[   treenew_treenew_sectnode	largetreer5   appendixpendingnodesectnamenewnodessubdirro   s                   r/   rf   zTexinfoBuilder.assemble_doctree}   s   YK*455Ii((3.T:::x##I..#Y 
	 $$677H}H$<$<> > >H HX%566 ! !D D'dmY(1I;@ @	(	)! 	' 	'Gx++G44H")HYX&&&&BB011222##Iy$???$,,X-BCC 	/ 	/K!,/G"=1H$)N8X$F$F#GH!%  %%f-- OOEJqzz$:$:;;;OOEN5%$@$@AAAOOEJsOO444E	 $$X....r1   c                 .    |                                   d S r*   )copy_support_filesr-   s    r/   finishzTexinfoBuilder.finish   s    !!!!!r1   rw   c           	      |   | j         r1t          | j        j                  j        }t          | j         t          d          dt          | j                   | j        j        |          D ]}| j         |         }	 t          j
        | j        |dz             }t          |           t          t          j
        | j        |          t          j
        ||                     x# t          $ rK}t                               t          d          t          j
        | j        |          |           Y d }~d }~ww xY wd S d S )Nzcopying images... brown)stringify_funcz-figureszcannot copy image file %r: %s)imagesr   apprL   get_original_image_urir   r   rb   	verbosityr   rc   rd   r   r   srcdir	ExceptionrI   rJ   )r.   rw   r   srcdestimagedirerrs          r/   rv   zTexinfoBuilder.copy_image_files   sl   ; 	E)$(,77NN&t{B7K4L4Lg'*4;'7'79K6DF F F E E {3'E#yj:6MNNHh'''#DIdk3$?$?$(Ih$=$=? ? ? ?  E E ENN2&E#F#F#'9T[##>#>E E E E E E E EE	E 	EE Es   :A'C""
D7,AD22D7c                    	 t          t          d                    5  t                              dd           t	          t
          j                            t          d          | j	                   d d d            d S # 1 swxY w Y   d S # t          $ r3}t                              t          d          |           Y d }~d S d }~ww xY w)Nzcopying Texinfo support filesz	Makefile Tr   Makefilezerror writing file Makefile: %s)r   r   rI   r   r   osr   rc   template_dirrd   OSErrorrJ   )r.   r   s     r/   r   z!TexinfoBuilder.copy_support_files   s#   	G!"%D"E"EFF U UKd333\: F FTTTU U U U U U U U U U U U U U U U U U  	G 	G 	GNN2?@@#FFFFFFFFF	Gs;   B AB 3B  BB BB 
C
(CC
)r(   Nr*   )__name__
__module____qualname____doc__nameformatr   epilogr   supported_image_typesr!   default_translator_classr0   r	   strr   r4   r9   r=   rR   r   ru   boolr
   documentrf   r   rv   r   r3   r1   r/   r&   r&       s         DFR677F	w' I"" H I I 	I* * *0V V V V5d3i#8    ! !c ! !s ! ! ! !, ,c ,s , , , , , ,4 4 4 4&'7c '7d '7 '7 '7 '7R(# (T (tTWy (]b]k ( ( ( (T" " " "E3 E4 E E E E G G G G G Gr1   r&   rG   r(   c                 \    t          | j                  }| j        || j        | j        |ddfgS )z, Better default texinfo_documents settings. zOne line description of projectMiscellaneous)r    projectroot_docrn   )rG   filenames     r/   default_texinfo_documentsr      s9    )&.99H_hx.A B Br1   r   c                    |                      t                     |                     dt          d            |                     dg d            |                     di d            |                     ddd t          g           |                     ddd            |                     dd	d            |                     d
dd            ddddS )NrH   re   rq   texinfo_domain_indicesTtexinfo_show_urlsfootnotetexinfo_no_detailmenuFtexinfo_cross_referencesbuiltin)versionparallel_read_safeparallel_write_safe)add_builderr&   add_config_valuer   r@   )r   s    r/   setupr      s    OON###,.GNNN-r4888+R66614vFFF,j$???0%>>>3T4@@@ "#  r1   )?r   r   rh   r   typingr   r   r   r   r   r	   docutilsr
   docutils.frontendr   docutils.ior   docutils.nodesr   sphinxr   r   sphinx.applicationr   sphinx.buildersr   sphinx.configr   !sphinx.environment.adapters.assetr   sphinx.errorsr   sphinx.localer   r   sphinx.utilr   r   r   sphinx.util.consoler   sphinx.util.docutilsr   sphinx.util.fileutilr   sphinx.util.nodesr   sphinx.util.osutilr   r   r    sphinx.writers.texinfor!   r"   	getLoggerr   rI   rc   r   r&   r   r   r   r3   r1   r/   <module>r      s     				        : : : : : : : : : : : : : : : :       * * * * * * " " " " " "       ( ( ( ( ( ( ( ( % % % % % % # # # # # #             : : : : : :               B B B B B B B B B B ) ) ) ) ) ) - - - - - - 0 0 0 0 0 0 1 1 1 1 1 1 I I I I I I I I I I C C C C C C C C		8	$	$w||Ki@@`G `G `G `G `GW `G `G `GFBf BeCc3PSUXZ]<]6^1_ B B B Bv $sCx.      r1   