
    Fe                        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 ddlmZmZmZ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# e$ r	 dd
lmZ Y (w xY w)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)path)TYPE_CHECKING)
build_main)blueboldcolor_terminalnocolor)rmtree)chdir)_chdir)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                  V    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                2    || _         || _        g || _        y N)srcdirbuilddiropts)selfr-   r.   r/   s       6/usr/lib/python3/dist-packages/sphinx/cmd/make_mode.py__init__zMake.__init__B   s     dG	    c                B    t        j                  | j                  g| S r,   )r   joinr.   )r0   compss     r1   builddir_joinzMake.builddir_joinG   s    yy///r3   c                ~   t        j                  | j                        }t        j                  | j                        }t        j                  | j                        syt        j
                  | j                        st        d| j                  z         y||k(  rt        d| j                  z         yt        j                  ||g      |k(  rt        d| j                  z         yt        d| j                  z         t        j                  | j                        D ]  }t        | j                  |              y)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
commonpathoslistdirr   r7   )r0   r-   r.   items       r1   build_cleanzMake.build_cleanJ   s    dkk*<<.{{4==)DMM*1DMMABx:T]]JK__fh/0H<BT]]RS/$--?@JJt}}- 	-D4%%d+,	-r3   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   BUILDERSr?   nameljust)r0   osnamebnamedescriptions       r1   
build_helpzMake.build_help]   s    Id<&"<"<<=>7DN;Lq;PQR*2 	C&FE;RWW.4B01K=AB	Cr3   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   r9   win32zmake.batmakeMAKEInvalid $MAKE command: %rzall-pdfError: Failed to run: %srun_generic_buildsysplatformr?   environgetlower
startswithRuntimeErrorr   r7   
subprocesscallOSErrorr=   r0   make_fallbackmakecmds      r1   build_latexpdfzMake.build_latexpdfg       !!'*Q. '*llg&=
6**..7}}))&1:WDEE	t))'23 =!';<= = = 	,w67	0   ;C B6,	C 6B?;C ?C CC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rQ   rW   rc   s      r1   build_latexpdfjazMake.build_latexpdfjaw   rg   rh   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   r9   rT   rS   rU   r    rV   )rX   r?   r[   r\   r]   r^   r_   r   r7   r`   ra   rb   r=   )r0   re   s     r1   
build_infozMake.build_info   s    !!),q0 **..0}}))&1:WDEE	t)))45 :!'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   r9   )r7   rX   )r0   dtdirs     r1   build_gettextzMake.build_gettext   s2    ""9k:!!)!>Br3   Nc                   t        j                  dd      }| j                  }|dv r|j                  dd|z   dz   g       || j	                  d      }d|d	|| j
                  | j	                  |      g}t        ||z         S )
NPAPERr   )a4letterz-Dzlatex_elements.papersize=paperdoctreesz-bz-d)r?   getenvr/   extendr7   r-   r   )r0   builderrn   	papersizer/   argss         r1   rX   zMake.run_generic_build   s    IIgr*	yy((KK:YFPQR++J7Jgj""7+- $+&&r3   )r-   strr.   r|   r/   Sequence[str]returnNone)r6   r|   r~   r|   )r~   int)r~   r   r,   )ry   r|   rn   z
str | Noner~   r   )__name__
__module____qualname__r2   r7   rB   rO   rf   rj   rl   rp   rX    r3   r1   r*   r*   A   s0    
0&C  'r3   r*   c                    t        |       dk  rt        dt        j                         yt	        | d   | d   | dd        }d| d   z   }t        ||      r t        ||             S |j                  | d         S )N   zJError: at least 3 arguments (builder, source dir, build dir) are required.)filer9   rE   build_r   )lenr=   rY   stderrr*   hasattrgetattrrX   )r{   rS   
run_methods      r1   run_make_moder      s    
4y1} .47JJ	@Qa$qr(+DDG#JtZ (wtZ(**!!$q'**r3   )r{   r}   r~   r   )__doc__
__future__r   r?   r`   rY   r   typingr   rG   sphinx.cmd.buildr   sphinx.util.consoler   r   r	   r
   sphinx.util.osutilr   
contextlibr   ImportErrorr   collections.abcr   rI   r*   r   r   r3   r1   <module>r      sq    # 	  
     '  &3  (:h' h'V	+]  323s   A A-,A-