
    }c                         d 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Zddlm	Z	 ddl
mZmZmZmZ ddlmZmZ g dZ G d	 d
          Zdee         defdZdS )a  sphinx-build -M command-line handling.

This replaces the old, platform-dependent and once-generated content
of Makefile / make.bat.

This is in its own module so that importing it is fast.  It should not
import the main Sphinx modules (like sphinx.applications, sphinx.builders).
    N)path)List)
build_main)blueboldcolor_terminalnocolor)cdrmtree)) htmlzto make standalone HTML files)r   dirhtmlz2to make HTML files named index.html in directories)r   
singlehtmlz to make a single large HTML file)r   picklezto make pickle files)r   jsonzto make JSON files)r   htmlhelpz+to make HTML files and an HTML help project)r   qthelpz'to make HTML files and a qthelp project)r   devhelpz(to make HTML files and a Devhelp project)r   epubzto make an epub)r   latexz9to make LaTeX files, you can set PAPER=a4 or PAPER=letter)posixlatexpdfz.to make LaTeX and PDF files (default pdflatex))r   
latexpdfjaz8to make LaTeX files and run them through platex/dvipdfmx)r   textzto make text files)r   manzto make manual pages)r   texinfozto make Texinfo files)r   infoz3to make Texinfo files and run them through makeinfo)r   gettextzto make PO message catalogs)r   changesz9to make an overview of all changed/added/deprecated items)r   xmlz!to make Docutils-native XML files)r   	pseudoxmlz0to make pseudoxml-XML files for display purposes)r   	linkcheckz)to check all external links for integrity)r   doctestz>to run all doctests embedded in the documentation (if enabled))r   coveragez7to run coverage check of the documentation (if enabled))r   cleanz+to remove everything in the build directoryc                       e Zd Zdededee         ddfdZdedefdZdefd	Zdd
Z	defdZ
defdZdefdZdefdZddededefdZdS )MakesrcdirbuilddiroptsreturnNc                 z    || _         || _        || _        t          j                            dd          | _        d S )NMAKEmake)r(   r)   r*   osenvirongetmakecmd)selfr(   r)   r*   s       4lib/python3.11/site-packages/sphinx/cmd/make_mode.py__init__zMake.__init__3   s2     	z~~ff55    compsc                 0    t          j        | j        g|R  S N)r   joinr)   )r3   r7   s     r4   builddir_joinzMake.builddir_join9   s    y/////r6   c                 R   t          j        | j                  }t          j        | j                  }t          j        | j                  sdS t          j        | j                  st          d| j        z             dS ||k    rt          d| j        z             dS t          j        ||g          |k    rt          d| j        z             dS t          d| j        z             t          j	        | j                  D ]$}t          |                     |                     %dS )Nr   zError: %r is not a directory!   z&Error: %r is same as source directory!z.Error: %r directory contains source directory!zRemoving everything under %r...)r   abspathr(   r)   existsisdirprint
commonpathr/   listdirr   r;   )r3   r(   r)   items       r4   build_cleanzMake.build_clean<   s    dk**<..{4=)) 
	1DM** 	1DMABBB1x 	:T]JKKK1_fh/00H< 	BT]RSSS1/$-?@@@Jt}-- 	- 	-D4%%d++,,,,qr6   c           	         t                      st                       t          t          dt          j        z                       t          dt          d          fdz  z             t          D ]M\  }}}|rt          j	        |k    r5t          dt          |
                    d                    d|           Nd S )Nz
Sphinx v%sz'Please use `make %s' where %s is one oftarget   z  
   )r   r	   rA   r   sphinx__display_version__r   BUILDERSr/   nameljust)r3   osnamebnamedescriptions       r4   
build_helpzMake.build_helpO   s     	IIId<&"<<==>>>7DNN;Lq;PQRRR*2 	I 	I&FE; IRW. IDR$9$9$9$9;;GHHH	I 	Ir6   c                    |                      d          dk    rdS t          j        dk    r!t          j                            dd          }n| j        }	 t          |                     d                    5  t          j
        |dg          cd d d            S # 1 swxY w Y   d S # t          $ r t          d|z             Y dS w xY w	Nr   r   r=   win32r-   zmake.batzall-pdfError: Failed to run: %srun_generic_buildsysplatformr/   r0   r1   r2   r
   r;   
subprocesscallOSErrorrA   r3   r2   s     r4   build_latexpdfzMake.build_latexpdfY      !!'**Q. 	1<7" 	#jnnVZ88GGlG	D&&w//00 = =!';<<= = = = = = = = = = = = = = = = = = 	 	 	,w677711	6   "B' 7BB' BB' !B"B' 'CCc                    |                      d          dk    rdS t          j        dk    r!t          j                            dd          }n| j        }	 t          |                     d                    5  t          j
        |dg          cd d d            S # 1 swxY w Y   d S # t          $ r t          d|z             Y dS w xY wrT   rW   r^   s     r4   build_latexpdfjazMake.build_latexpdfjah   r`   ra   c                 8   |                      d          dk    rdS 	 t          |                     d                    5  t          j        | j        dg          cd d d            S # 1 swxY w Y   d S # t          $ r t          d| j        z             Y dS w xY w)Nr   r   r=   r   rV   )rX   r
   r;   r[   r\   r2   r]   rA   )r3   s    r4   
build_infozMake.build_infow   s    !!),,q0 	1	D&&y1122 ? ?!f'=>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 	 	 	,t|;<<<11	s4   "A4 A'A4 'A++A4 .A+/A4 4!BBc                 l    |                      dd          }|                     d|          dk    rdS dS )Nr   z	.doctrees)
doctreedirr   r=   )r;   rX   )r3   dtdirs     r4   build_gettextzMake.build_gettext   sA    ""9k::!!)!>>B 	1qr6   builderrg   c                    t          j        dd          }| j        }|dv r|                    dd|z   dz   g           ||                     d          }d|d	|| j        |                     |          g}t          ||z             S )
NPAPERr   )a4letterz-Dzlatex_elements.papersize=paperdoctreesz-bz-d)r/   getenvr*   extendr;   r(   r   )r3   rj   rg   	papersizer*   argss         r4   rX   zMake.run_generic_build   s    Igr**	y(( 	SKK:YFPQRRR 	8++J77Jgj""7++- $+&&&r6   )r+   Nr9   )__name__
__module____qualname__strr   r5   r;   intrE   rR   r_   rc   re   ri   rX    r6   r4   r'   r'   2   s7       6s 6c 6c 6t 6 6 6 60C 0C 0 0 0 0S    &I I I I    #    C    s    ' ' '# ' ' ' ' ' ' 'r6   r'   rt   r+   c                 H   t          |           dk     rt          dt          j                   dS t	          | d         | d         | dd                    }d| d         z   }t          ||          r t          ||                      S |                    | d                   S )N   zJError: at least 3 arguments (builder, source dir, build dir) are required.)filer=   rH   build_r   )lenrA   rY   stderrr'   hasattrgetattrrX   )rt   r.   
run_methods      r4   run_make_moder      s    
4yy1}  .47J	@ 	@ 	@ 	@qQa$qrr(++DDG#JtZ   +(wtZ((***!!$q'***r6   )__doc__r/   r[   rY   r   typingr   rJ   sphinx.cmd.buildr   sphinx.util.consoler   r   r   r	   sphinx.util.osutilr
   r   rL   r'   rx   ry   r   rz   r6   r4   <module>r      s    
			     



              ' ' ' ' ' ' C C C C C C C C C C C C ) ) ) ) ) ) ) )  :b' b' b' b' b' b' b' b'J	+S	 	+c 	+ 	+ 	+ 	+ 	+ 	+r6   