o $a@sdZddlZddlZddlZddlmZddlmZddlZddlm Z ddl m Z m Z m Z mZddlmZmZgdZGd d d Zd eed efd dZdS)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-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)path)List) build_main)blueboldcolor_terminalnocolor)cdrmtree))htmlzto make standalone HTML files)r dirhtmlz2to make HTML files named index.html in directories)r singlehtmlz to make a single large HTML file)r picklezto make pickle files)r jsonzto 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 epubzto make an epub)r latexz9to make LaTeX files, you can set PAPER=a4 or PAPER=letter)posixlatexpdfz.to make LaTeX and PDF files (default pdflatex))r latexpdfjaz8to make LaTeX files and run them through platex/dvipdfmx)r textzto make text files)r manzto make manual pages)r texinfozto make Texinfo files)rinfoz3to make Texinfo files and run them through makeinfo)r gettextzto 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@seZdZdededeeddfddZdedefd d Zdefd d Zdd dZ defddZ defddZ defddZ defddZ ddededefddZdS)MakesrcdirbuilddiroptsreturnNcCs&||_||_||_tjdd|_dS)NMAKEmake)r&r'r(osenvirongetmakecmd)selfr&r'r(r16/usr/lib/python3/dist-packages/sphinx/cmd/make_mode.py__init__:sz Make.__init__compscGstj|jg|RSN)rjoinr')r0r4r1r1r2 builddir_join@szMake.builddir_joincCst|j}t|j}t|jsdSt|js#td|jdS||kr0td|jdSt||g|krBtd|jdStd|jt |jD] }t | |qOdS)NrzError: %r is not a directory!z&Error: %r is same as source directory!z.Error: %r directory contains source directory!zRemoving everything under %r...) rabspathr&r'existsisdirprint commonpathr,listdirr r7)r0r&r'itemr1r1r2 build_cleanCs"    zMake.build_cleancCsptstttdtjtdtdfdtD]\}}}|r(tj |kr5tdt| d|fqdS)Nz Sphinx v%sz'Please use `make %s' where %s is one oftargetz %s %s ) rrr<rsphinx__display_version__rBUILDERSr,nameljust)r0osnamebname descriptionr1r1r2 build_helpVszMake.build_helpcC|ddkr dStjdkrtjdd}n|j}z"t|dt |dgWdWS1s4wYWdSt yKt d|YdSw Nrrr8win32r*zmake.batzall-pdfError: Failed to run: %s run_generic_buildsysplatformr,r-r.r/r r7 subprocesscallOSErrorr<r0r/r1r1r2build_latexpdf`  (  zMake.build_latexpdfcCrMrNrQrXr1r1r2build_latexpdfjaorZzMake.build_latexpdfjacCs||ddkr dSz#t|dt|jdgWdWS1s%wYWdSty=td|jYdSw)Nrrr8rrP)rRr r7rUrVr/rWr<)r0r1r1r2 build_info~s( zMake.build_infocCs&|dd}|jd|ddkrdSdS)Nrz .doctrees) doctreedirrr8)r7rR)r0dtdirr1r1r2 build_gettexts zMake.build_gettextbuilderr]cCsftdd}|j}|dvr|dd|dg|dur!|d}d|d ||j||g}t||S) NPAPERr )a4letterz-Dzlatex_elements.papersize=paperdoctreesz-bz-d)r,getenvr(extendr7r&r)r0r`r] papersizer(argsr1r1r2rRs   zMake.run_generic_build)r)Nr5)__name__ __module__ __qualname__strrr3r7intr@rLrYr[r\r_rRr1r1r1r2r%9s   r%rir)cCsjt|dkrtdtjddSt|d|d|dd}d|d}t||r.t||S||dS)NzJError: at least 3 arguments (builder, source dir, build dir) are required.)filer8rBbuild_r)lenr<rSstderrr%hasattrgetattrrR)rir+ run_methodr1r1r2 run_make_modes    rw)__doc__r,rUrSrtypingrrDsphinx.cmd.buildrsphinx.util.consolerrrrsphinx.util.osutilr r rFr%rmrnrwr1r1r1r2s   e