ó
öÀ„\c           @  s%  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 Z d d l m	 Z	 d d l
 m Z m Z m Z m Z d d l m Z m Z e r· d d l m Z n  d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR g Z d9 e f d: „  ƒ  YZ d; „  Z d S(S   sÓ  
    sphinx.cmd.make_mode
    ~~~~~~~~~~~~~~~~~~~~

    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).

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿ(   t   print_functionN(   t   path(   t
   build_main(   t   color_terminalt   nocolort   boldt   blue(   t   cdt   rmtree(   t   Listt    t   htmls   to make standalone HTML filest   dirhtmls2   to make HTML files named index.html in directoriest
   singlehtmls    to make a single large HTML filet   pickles   to make pickle filest   jsons   to make JSON filest   htmlhelps+   to make HTML files and an HTML help projectt   qthelps'   to make HTML files and a qthelp projectt   devhelps(   to make HTML files and a Devhelp projectt   epubs   to make an epubt   latexs9   to make LaTeX files, you can set PAPER=a4 or PAPER=lettert   posixt   latexpdfs.   to make LaTeX and PDF files (default pdflatex)t
   latexpdfjas8   to make LaTeX files and run them through platex/dvipdfmxt   texts   to make text filest   mans   to make manual pagest   texinfos   to make Texinfo filest   infos3   to make Texinfo files and run them through makeinfot   gettexts   to make PO message catalogst   changess9   to make an overview of all changed/added/deprecated itemst   xmls!   to make Docutils-native XML filest	   pseudoxmls0   to make pseudoxml-XML files for display purposest	   linkchecks)   to check all external links for integrityt   doctests>   to run all doctests embedded in the documentation (if enabled)t   coverages7   to run coverage check of the documentation (if enabled)t   Makec           B  s\   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 d „ Z RS(
   c         C  s7   | |  _  | |  _ | |  _ t j j d d ƒ |  _ d  S(   Nt   MAKEt   make(   t   srcdirt   builddirt   optst   ost   environt   gett   makecmd(   t   selfR&   R'   R(   (    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   __init__@   s    			c         G  s   t  j |  j | Œ S(   N(   R   t   joinR'   (   R-   t   comps(    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   builddir_joinG   s    c         C  s‚   t  j |  j ƒ s d St  j |  j ƒ s= t d |  j ƒ d St d |  j ƒ x- t j |  j ƒ D] } t |  j | ƒ ƒ qa Wd S(   Ni    s   Error: %r is not a directory!i   s   Removing everything under %r...(	   R   t   existsR'   t   isdirt   printR)   t   listdirR   R1   (   R-   t   item(    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   build_cleanK   s    c         C  sŸ   t  ƒ  s t ƒ  n  t t d t j ƒ ƒ t d t d ƒ f d ƒ xS t D]K \ } } } | sq t j	 | k rL t d t | j
 d ƒ ƒ | f ƒ qL qL Wd  S(   Ns
   Sphinx v%ss'   Please use `make %s' where %s is one oft   targeti   s     %s  %si
   (   R   R   R4   R   t   sphinxt   __display_version__R   t   BUILDERSR)   t   namet   ljust(   R-   t   osnamet   bnamet   description(    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt
   build_helpW   s    	
c         C  s£   |  j  d ƒ d k r d St j d k r@ t j j d d ƒ } n	 |  j } y3 t |  j d ƒ ƒ  t	 j
 | d g ƒ SWd  QXWn  t k
 rž t d | ƒ d SXd  S(	   NR   i    i   t   win32R$   s   make.bats   all-pdfs   Error: Failed to run: %s(   t   run_generic_buildt   syst   platformR)   R*   R+   R,   R   R1   t
   subprocesst   callt   OSErrorR4   (   R-   R,   (    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   build_latexpdfb   s    	c         C  s£   |  j  d ƒ d k r d St j d k r@ t j j d d ƒ } n	 |  j } y3 t |  j d ƒ ƒ  t	 j
 | d g ƒ SWd  QXWn  t k
 rž t d | ƒ d SXd  S(	   NR   i    i   RB   R$   s   make.bats   all-pdfs   Error: Failed to run: %s(   RC   RD   RE   R)   R*   R+   R,   R   R1   RF   RG   RH   R4   (   R-   R,   (    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   build_latexpdfjar   s    	c         C  sy   |  j  d ƒ d k r d Sy6 t |  j d ƒ ƒ  t j |  j d g ƒ SWd  QXWn# t k
 rt t d |  j ƒ d SXd  S(   NR   i    i   R   s   Error: Failed to run: %s(   RC   R   R1   RF   RG   R,   RH   R4   (   R-   (    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt
   build_info‚   s     c         C  s5   |  j  d d ƒ } |  j d d | ƒd k r1 d Sd S(   NR   s	   .doctreest
   doctreediri    i   (   R1   RC   (   R-   t   dtdir(    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   build_gettext   s    c         C  s•   t  j d d ƒ } |  j } | d k rE | j d d | d g ƒ n  | d  k rc |  j d ƒ } n  d	 | d
 | |  j |  j | ƒ g } t | | ƒ S(   Nt   PAPERR
   t   a4t   letters   -Ds   latex_elements.papersize=t   papert   doctreess   -bs   -d(   RP   RQ   (   R)   t   getenvR(   t   extendt   NoneR1   R&   R   (   R-   t   builderRL   t	   papersizeR(   t   args(    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyRC   ”   s    	N(   t   __name__t
   __module__R.   R1   R7   RA   RI   RJ   RK   RN   RV   RC   (    (    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyR#   >   s   								c         C  s…   t  |  ƒ d k  r) t d d t j ƒd St |  d |  d |  d ƒ } d |  d } t | | ƒ rt t | | ƒ ƒ  S| j |  d ƒ S(   Ni   sJ   Error: at least 3 arguments (builder, source dir, build dir) are required.t   filei   i   t   build_i    (   t   lenR4   RD   t   stderrR#   t   hasattrt   getattrRC   (   RY   R%   t
   run_method(    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   run_make_mode¥   s    	
(   R
   R   s   to make standalone HTML files(   R
   R   s2   to make HTML files named index.html in directories(   R
   R   s    to make a single large HTML file(   R
   R   s   to make pickle files(   R
   R   s   to make JSON files(   R
   R   s+   to make HTML files and an HTML help project(   R
   R   s'   to make HTML files and a qthelp project(   R
   R   s(   to make HTML files and a Devhelp project(   R
   R   s   to make an epub(   R
   R   s9   to make LaTeX files, you can set PAPER=a4 or PAPER=letter(   R   R   s.   to make LaTeX and PDF files (default pdflatex)(   R   R   s8   to make LaTeX files and run them through platex/dvipdfmx(   R
   R   s   to make text files(   R
   R   s   to make manual pages(   R
   R   s   to make Texinfo files(   R   R   s3   to make Texinfo files and run them through makeinfo(   R
   R   s   to make PO message catalogs(   R
   R   s9   to make an overview of all changed/added/deprecated items(   R
   R   s!   to make Docutils-native XML files(   R
   R   s0   to make pseudoxml-XML files for display purposes(   R
   R    s)   to check all external links for integrity(   R
   R!   s>   to run all doctests embedded in the documentation (if enabled)(   R
   R"   s7   to run coverage check of the documentation (if enabled)(   t   __doc__t
   __future__R    R)   RF   RD   R   R9   t   sphinx.cmd.buildR   t   sphinx.util.consoleR   R   R   R   t   sphinx.util.osutilR   R   t   Falset   typingR	   R;   t   objectR#   Rc   (    (    (    s3   lib/python2.7/site-packages/sphinx/cmd/make_mode.pyt   <module>   sH   "	g