
    Ri"!                        d Z ddlm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mZmZmZ ddlmZ ddlmZ dd	lmZ e	rdd
lmZ g dZ G d d      ZddZy)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).
    )annotationsN)chdir)TYPE_CHECKING)bluebolddisable_colourterminal_supports_colour)
build_main)_StrPath)rmtree)Sequence)) 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                  r    e Zd Z	 	 	 	 	 	 	 	 ddZddZddZddZddZddZddZ	ddZ
	 d	 	 	 	 	 dd
Zy	)Makec               V    t        |      | _        t        |      | _        g || _        y N)r   
source_dir	build_diropts)selfr,   r-   r.   s       L/home/agent/.friday_env/lib/python3.12/site-packages/sphinx/cmd/make_mode.py__init__zMake.__init__<   s'     #:.!),dG	    c                4     | j                   j                  | S r+   )r-   joinpath)r/   compss     r0   build_dir_joinzMake.build_dir_joinG   s    &t~~&&..r2   c                   | j                   j                         }| j                  j                         }| j                  j                         sy| j                  j	                         st        d| j                  z         y||k(  rt        d| j                  z         y|j                  |      rt        d| j                  z         yt        d| j                  z         | j                  j                         D ]  }t        |        y)Nr   zError: '%s' is not a directory!   z(Error: '%s' is same as source directory!z0Error: '%s' directory contains source directory!z!Removing everything under '%s'...)	r,   resolver-   existsis_dirprintis_relative_toiterdirr   )r/   r,   r-   items       r0   build_cleanzMake.build_cleanJ   s    __,,.
NN**,	~~$$&&&(3dnnDE9$<t~~MN&&y1Dt~~UV1DNNBCNN**, 	D4L	r2   c           	     H   t               s
t                t        t        dt        j
                  z               t        dt        d      fdz  z         t        D ]E  \  }}}|rt        j                  |k(  st        dt        |j                  d             d|        G y )Nz
Sphinx v%sz'Please use `make %s' where %s is one oftarget   z  
   )r	   r   r<   r   sphinx__display_version__r   BUILDERSosnameljust)r/   osnamebnamedescriptions       r0   
build_helpzMake.build_help]   s    ')d<&"<"<<=>7DN;Lq;PQR*2 	C&FE;RWW.4B01K=AB	Cr2   c                F   | j                  d      dkD  ryt        j                  dk(  rdnd}t        j                  j                  d|      }|j                         j                  d      st        d|z        	 t        | j                  d            5  d	| j                  v rat        d
dd      5 }t        j                  |ddg|t        j                        }d d d        r}t!        d| j                  dd
      z         n^d| j                  v r9t        j                  |dddg      }|r5t!        d| j                  d      z         nt        j                  |dg      }|cd d d        S # 1 sw Y   xY w# 1 sw Y   y xY w# t"        $ r t!        d|z         Y yw xY w)Nr   r   r8   win32make.batmakeMAKEInvalid $MAKE command: %rz-Q__LATEXSTDOUT__wzutf-8)encodingall-pdfzLATEXOPTS=-halt-on-error)stdoutstderrzLatex error: check %sz-qzLATEXMKOPTS=-silentz"Latex error: check .log file in %sError: Failed to run: %s)run_generic_buildsysplatformrH   environgetlower
startswithRuntimeErrorr   r6   r.   open
subprocesscallSTDOUTr<   OSError)r/   make_fallbackmakecmdoutfile
returncodes        r0   build_latexpdfzMake.build_latexpdfg   s   !!'*Q. '*llg&=
6**..7}}))&1:WDEE%	t**734 !"499$/wG 	7%/__ ' ) :
 $+#-#4#4&
	 "3"11';LMN TYY&!+#%61	"J "@"11':;
 ",'91E!FJ!C!" !"	 	!" !"D  	,w67	sI   ;F E:2*E.BE:$	F .E7	3E::F?F F F F c                   | j                  d      dkD  ryt        j                  dk(  rdnd}t        j                  j                  d|      }|j                         j                  d      st        d|z        	 t        | j                  d            5  t        j                  |d	g      cd d d        S # 1 sw Y   y xY w# t        $ r t        d
|z         Y yw xY w)Nr   r   r8   rP   rQ   rR   rS   rT   rX   r[   )r\   r]   r^   rH   r_   r`   ra   rb   rc   r   r6   re   rf   rh   r<   )r/   ri   rj   s      r0   build_latexpdfjazMake.build_latexpdfja   s    !!'*Q. '*llg&=
6**..7}}))&1:WDEE	t**734 =!';<= = = 	,w67	s0   ;C B6,	C 6B?;C ?C CCc                   | j                  d      dkD  ryt        j                  j                  dd      }|j	                         j                  d      st        d|z        	 t        | j                  d            5  t        j                  |dg      cd d d        S # 1 sw Y   y xY w# t        $ r t        d|z         Y yw xY w)	Nr   r   r8   rS   rR   rT   r   r[   )r\   rH   r_   r`   ra   rb   rc   r   r6   re   rf   rh   r<   )r/   rj   s     r0   
build_infozMake.build_info   s    !!),q0 **..0}}))&1:WDEE	t**956 :!'89: : : 	,w67	s0   $B+ >B	B+ B($B+ (B+ +CCc                V    | j                  dd      }| j                  d|      dkD  ryy)Nr    z	.doctrees)
doctreedirr   r8   )r6   r\   )r/   dtdirs     r0   build_gettextzMake.build_gettext   s2    ##I{;!!)!>Br2   Nc           
     F   t        j                  dd      }|dv r!| j                  j                  dd| dg       || j	                  d      }d|d	t        |      t        | j                        t        | j	                  |            g}t        || j                  z         S )
NPAPERr   >   a4letterz-Dzlatex_elements.papersize=paperdoctreesz	--builderz--doctree-dir)rH   getenvr.   extendr6   strr,   r
   )r/   builderrs   
paper_sizeargss        r0   r\   zMake.run_generic_build   s     YYw+
))IId&?
|5$QRS,,Z8J 
O ##G,-
 $*++r2   )r,   str | os.PathLike[str]r-   r   r.   Sequence[str]returnNone)r5   r   r   r   )r   int)r   r   r+   )r   r~   rs   zstr | os.PathLike[str] | Noner   r   )__name__
__module____qualname__r1   r6   r@   rN   rm   ro   rq   ru   r\    r2   r0   r)   r)   ;   sx    	 +	 *		
 	 
	/&C.`  IM,,(E,	,r2   r)   c                    t        |       dk  rt        dt        j                         y| d   }t	        | d   | d   | dd        }d| }t        ||      r t        ||             S |j                  |      S )	N   zJError: at least 3 arguments (builder, source dir, build dir) are required.)filer8   r   rC   )r,   r-   r.   build_)lenr<   r]   rZ   r)   hasattrgetattrr\   )r   builder_namerR   
run_methods       r0   run_make_moder      s    
4y1},	

 7L47d1gDHED,(JtZ (wtZ(**!!,//r2   )r   r   r   r   )__doc__
__future__r   rH   re   r]   
contextlibr   typingr   rE   sphinx._cli.util.colourr   r   r   r	   sphinx.cmd.buildr
   sphinx.util._pathlibr   sphinx.util.osutilr   collections.abcr   rG   r)   r   r   r2   r0   <module>r      sP    # 	  
     X X ' ) %(@S, S,l0r2   