B
    öÀ„\E  ã               @   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 dd	d
ddddddddddddddddddddgZG dd „ d eƒZd!d"„ ZdS )#aÓ  
    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.
é    )Úprint_functionN)Úpath)Ú
build_main)Úcolor_terminalÚnocolorÚboldÚblue)ÚcdÚrmtree)Ú Zhtmlzto make standalone HTML files)r   Zdirhtmlz2to make HTML files named index.html in directories)r   Z
singlehtmlz to make a single large HTML file)r   Úpicklezto make pickle files)r   Zjsonzto make JSON files)r   Zhtmlhelpz+to make HTML files and an HTML help project)r   Zqthelpz'to make HTML files and a qthelp project)r   Zdevhelpz(to make HTML files and a Devhelp project)r   Zepubzto make an epub)r   Úlatexz9to make LaTeX files, you can set PAPER=a4 or PAPER=letter)ÚposixZlatexpdfz.to make LaTeX and PDF files (default pdflatex))r   Z
latexpdfjaz8to make LaTeX files and run them through platex/dvipdfmx)r   Útextzto make text files)r   Z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   Zchangesz9to make an overview of all changed/added/deprecated items)r   Zxmlz!to make Docutils-native XML files)r   Z	pseudoxmlz0to make pseudoxml-XML files for display purposes)r   Z	linkcheckz)to check all external links for integrity)r   Zdoctestz>to run all doctests embedded in the documentation (if enabled))r   Zcoveragez7to run coverage check of the documentation (if enabled)c               @   sV   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dS )ÚMakec             C   s&   || _ || _|| _tj dd¡| _d S )NÚMAKEÚmake)ÚsrcdirÚbuilddirÚoptsÚosÚenvironÚgetÚmakecmd)Úselfr   r   r   © r   ú3lib/python3.7/site-packages/sphinx/cmd/make_mode.pyÚ__init__@   s    zMake.__init__c             G   s   t j| jf|žŽ S )N)r   Újoinr   )r   Úcompsr   r   r   Úbuilddir_joinG   s    zMake.builddir_joinc             C   sd   t  | j¡sdS t  | j¡s.td| j ƒ dS td| j ƒ x"t | j¡D ]}t|  |¡ƒ qJW dS )Nr   zError: %r is not a directory!é   zRemoving everything under %r...)	r   Úexistsr   ÚisdirÚprintr   Úlistdirr
   r#   )r   Úitemr   r   r   Úbuild_cleanK   s    zMake.build_cleanc             C   st   t ƒ stƒ  ttdtj ƒƒ tdtdƒfd  ƒ x:tD ]2\}}}|rRtj	|kr:tdt| 
d¡ƒ|f ƒ q:W d S )Nz
Sphinx v%sz'Please use `make %s' where %s is one ofÚtargeté   z  %s  %sé
   )r   r   r'   r   ÚsphinxZ__display_version__r   ÚBUILDERSr   ÚnameÚljust)r   ZosnameZbnameZdescriptionr   r   r   Ú
build_helpW   s    zMake.build_helpc          	   C   s€   |   d¡dkrdS tjdkr,tj dd¡}n| j}y(t|  d¡ƒ t	 
|dg¡S Q R X W n  tk
rz   td| ƒ dS X d S )	Nr   r   r$   Úwin32r   zmake.batzall-pdfzError: Failed to run: %s)Úrun_generic_buildÚsysÚplatformr   r   r   r   r	   r#   Ú
subprocessÚcallÚOSErrorr'   )r   r   r   r   r   Úbuild_latexpdfb   s    
zMake.build_latexpdfc          	   C   s€   |   d¡dkrdS tjdkr,tj dd¡}n| j}y(t|  d¡ƒ t	 
|dg¡S Q R X W n  tk
rz   td| ƒ dS X d S )	Nr   r   r$   r3   r   zmake.batzall-pdfzError: Failed to run: %s)r4   r5   r6   r   r   r   r   r	   r#   r7   r8   r9   r'   )r   r   r   r   r   Úbuild_latexpdfjar   s    
zMake.build_latexpdfjac          	   C   sd   |   d¡dkrdS y*t|  d¡ƒ t | jdg¡S Q R X W n" tk
r^   td| j ƒ dS X d S )Nr   r   r$   r   zError: Failed to run: %s)r4   r	   r#   r7   r8   r   r9   r'   )r   r   r   r   Ú
build_info‚   s    zMake.build_infoc             C   s&   |   dd¡}| jd|ddkr"dS dS )Nr   z	.doctrees)Ú
doctreedirr   r$   )r#   r4   )r   Zdtdirr   r   r   Úbuild_gettext   s    zMake.build_gettextNc             C   sf   t  dd¡}| j}|dkr0| dd| d g¡ |d krB|  d¡}d|d	|| j|  |¡g}t|| ƒS )
NZPAPERr   )Za4Zletterz-Dzlatex_elements.papersize=ZpaperZdoctreesz-bz-d)r   Úgetenvr   Úextendr#   r   r   )r   Zbuilderr=   Z	papersizer   Úargsr   r   r   r4   ”   s    
zMake.run_generic_build)N)Ú__name__Ú
__module__Ú__qualname__r    r#   r*   r2   r:   r;   r<   r>   r4   r   r   r   r   r   >   s   r   c             C   sj   t | ƒdk rtdtjd dS t| d | d | dd … ƒ}d| d  }t||ƒr\t||ƒƒ S | | d ¡S )Né   zJError: at least 3 arguments (builder, source dir, build dir) are required.)Úfiler$   r,   Zbuild_r   )Úlenr'   r5   Ústderrr   ÚhasattrÚgetattrr4   )rA   r   Z
run_methodr   r   r   Úrun_make_mode¥   s    

rK   )Ú__doc__Z
__future__r   r   r7   r5   r   r.   Zsphinx.cmd.buildr   Zsphinx.util.consoler   r   r   r   Zsphinx.util.osutilr	   r
   r/   Úobjectr   rK   r   r   r   r   Ú<module>   sD   g