3

T'ícÕ0ã@sÀdZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlZddlmZmZddlmZddlmZdd	lmZdd
lmZmZmZddlmZmZm Z m!Z!ddl"m#Z#m$Z$dd
l%m&Z&m'Z'ej(feee)eddœdd„Z*e+e,dœdd„Z-ej.dœdd„Z/ej0dd…fe
e+e,dœdd„Z1ej0dd…fe
e+e,dœdd„Z2ej0dd…fe
e+e,dœdd„Z3e4dkr¼ej5e3ej0dd…ƒƒdS) z+Build documentation from a provided source.éN)Úpath)ÚIOÚAnyÚList)Ú
SystemMessage)Ú__display_version__Úpackage_dir)ÚSphinx)ÚSphinxError)Ú__)ÚTeeÚformat_exception_cut_framesÚsave_traceback)Úcolor_terminalÚnocolorÚredÚ
terminal_safe)Údocutils_namespaceÚpatch_docutils)ÚabspathÚ	ensuredir)ÚappÚargsÚ	exceptionÚstderrÚreturncCs(t|tjƒrdS|jrHtttdƒƒ|dtjƒtj	t
jƒdƒnÜt|d|js^|jrttjd|ƒt|dt|t
ƒr’ttdƒ|dn’t|tƒrÊtttdƒƒ|dtt|jdƒ|dnZt|tƒrþttd|jƒ|dtt|ƒ|dn&t|tƒrTtttdƒƒ|dttt|ƒƒ|dt|ƒ}tttd	ƒ|ƒ|dnÐt|tƒr¾d
t|ƒkr¾tttdƒƒ|dttt|ƒƒ|dt|dttdƒ|dtd
|dnftttdƒƒ|dttƒjƒ|dt|ƒ}tttd	ƒ|ƒ|dttdƒ|dttdƒ|ddS)Nz5Exception occurred while building, starting debugger:)ÚfileézInterrupted!zreST markup error:rz%s:zEncoding error:z[The full traceback has been saved in %s, if you want to report the issue to the developers.zrecursion depthzRecursion error:zšThis can happen with very large or deeply nested source files. You can carefully increase the default Python recursion limit of 1000 in conf.py with e.g.:z+    import sys; sys.setrecursionlimit(1500)zException occurred:ziPlease also report this if it was a user error, so that a better error message can be provided next time.zbA bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!)Ú
isinstanceÚbdbZBdbQuitÚpdbÚprintrrÚ	tracebackÚ	print_excZpost_mortemÚsysÚexc_infoÚ	verbosityÚKeyboardInterruptrrrr
ÚcategoryÚstrÚUnicodeErrorrÚRuntimeErrorr
Úrstrip)rrrrZtbpath©r-ú2/tmp/pip-build-gk9425m9/sphinx/sphinx/cmd/build.pyÚhandle_exceptionsV








r/)ÚvaluercCs8|dkrtjƒSt|ƒ}|dkr0tjtdƒƒ‚n|SdS)z½
    Special type to handle 'auto' flags passed to 'sphinx-build' via -j flag. Can
    be expanded to handle other special scaling requests, such as setting job count
    to cpu_count.
    Úautorz&job number should be a positive numberN)ÚmultiprocessingÚ	cpu_countÚintÚargparseÚArgumentTypeErrorr)r0Újobsr-r-r.Ú
jobs_argumentOsr8)rcCsxtjdtdƒtdƒd}|jddddtd	|jd
tdƒd|jd
tdƒd|jddtdƒd|jtdƒƒ}|jddddtdƒd|jdddtdƒd|jddd td!ƒd|jd"d#d$td%ƒd&|jd'd(d)td*td+ƒd,|jd-ƒ}|jd.d#d/td0ƒd&|jd1dd2td3ƒd|jd4d5d6d7gtd8ƒd9|jd:d;d6d<gtd=ƒd9|jd>d?d6d@gtdAƒd9|jdBddCtdDƒd|jtdEƒƒ}|jdFdGdHdItdJƒdK|jdLddMtdNƒd|jdOddPtdQƒd|jdRdSdTdUtdVƒdW|jdXdYdZdSd[td\ƒd]|jd^d_d`tdaƒd&|jdbddctddƒd|jdeddftdgƒd|jdhdditdjƒd|jdkddltdmƒd|S)nNz5%(prog)s [OPTIONS] SOURCEDIR OUTPUTDIR [FILENAMES...]z:For more information, visit <https://www.sphinx-doc.org/>.a
Generate documentation from source files.

sphinx-build generates documentation from the files in SOURCEDIR and places it
in OUTPUTDIR. It looks for 'conf.py' in SOURCEDIR for the configuration
settings. The 'sphinx-quickstart' tool may be used to generate template files,
including 'conf.py'

sphinx-build can create documentation in different formats. A format is
selected by specifying the builder name on the command line; it defaults to
HTML. Builders can also perform other tasks related to documentation
processing.

By default, everything that is outdated is built. Output only for selected
files can be built by specifying individual filenames.
)ÚusageÚepilogÚdescriptionz	--versionÚversionZshow_versionz%%(prog)s %s)ÚactionÚdestr<Ú	sourcedirz"path to documentation source files)ÚhelpÚ	outputdirzpath to output directoryÚ	filenamesÚ*z?a list of specific files to rebuild. Ignored if -a is specified)Únargsr@zgeneral optionsz-bZBUILDERÚbuilderÚhtmlzbuilder to use (default: html))Úmetavarr>Údefaultr@z-aÚ
store_trueÚ	force_allz;write all files (default: only write new and changed files))r=r>r@z-EÚfreshenvz4don't use a saved environment, always read all filesz-dÚPATHÚ
doctreedirzPpath for the cached environment and doctree files (default: OUTPUTDIR/.doctrees))rGr>r@z-jÚNér7z`build in parallel with N processes where possible (special value "auto" will set N to cpu-count))rGrHÚtyper>r@zbuild configuration optionsz-cÚconfdirzOpath where configuration file (conf.py) is located (default: same as SOURCEDIR)z-CÚnoconfigz*use no config file at all, only -D optionsz-Dz
setting=valueÚappendÚdefinez(override a setting in configuration file)rGr=r>rHr@z-Az
name=valueÚ
htmldefinez pass a value into HTML templatesz-tZTAGÚtagsz*define tag: include "only" blocks with TAGz-nÚnitpickyz1nit-picky mode, warn about all missing referenceszconsole output optionsz-vÚcountr&rz$increase verbosity (can be repeated))r=r>rHr@z-qÚquietz,no output on stdout, just warnings on stderrz-QÚreally_quietz#no output at all, not even warningsz--colorÚstore_constÚyesr1z-do emit colored output (default: auto-detect))r=ÚconstrHr@z-Nz
--no-colorÚcolorÚnoz1do not emit colored output (default: auto-detect))r>r=r]r@z-wÚFILEÚwarnfilez)write warnings (and errors) to given filez-WÚwarningiserrorzturn warnings into errorsz--keep-goingÚ
keep_goingz)with -W, keep going when getting warningsz-Tr"z show full traceback on exceptionz-Pr zrun Pdb on exception)r5ÚArgumentParserrÚadd_argumentrÚadd_argument_groupr8)ÚparserÚgroupr-r-r.Ú
get_parser_s‚




















rirO)ÚargvrcCsddlm}|j|dd…ƒS)zSphinx build "make mode" entry.r)Ú	make_moderON)Z
sphinx.cmdrkZ
run_make_mode)rjrkr-r-r.Ú	make_main¾srlc1Cstƒ}|j|ƒ}|jrd|_n|js,|j|_|jsDtjj|j	dƒ|_|j
}g}x"|D]}tjj|ƒsT|j|ƒqTW|rˆ|j
tdƒ|ƒ|jr |r |j
tdƒƒ|jdks¼|jdkrÂtƒrÂtƒtj}tj}tj}|jrÞd}|jrìd}}|oô|jrly(t|jƒ}	ttj|	ƒƒt|jdƒ}
Wn<tk
r\}z|j
tdƒ|j|fƒWYdd}~XnXt||
ƒ}|}i}xR|jD]H}
y|
j d	d
ƒ\}}
Wn$t!k
r´|j
tdƒƒYnX|
||<qxWxx|j"D]n}
y|
j d	ƒ\}}
Wn$t!k
r|j
tdƒƒYnXyt#|
ƒ}
Wnt!k
r*YnX|
|d
|<qÌW|j$rNd|d<d}y€|jp`|j}t%|ƒ`t&ƒNt'|j|j|j	|j|j(||||j)|j*|j+|j,|j-|j.ƒ}|j/|j|ƒ|j0SQRXWdQRXWn4tt1fk
r}zt2||||ƒdSd}~XnXdS)z'Sphinx build "main" command-line entry.Nz	.doctreeszcannot find files %rz&cannot combine -a option and filenamesr_r1Úwzcannot open warning file %r: %sú=rOz1-D option argument must be in the form name=valuez1-A option argument must be in the form name=valuezhtml_context.%sTrWr)3riÚ
parse_argsrRrQr?rMÚosrÚjoinrArBÚisfilerSÚerrorrrJr^rrr$ÚstdoutrrYrZrarrÚdirnameÚopenÚ	ExceptionrrTÚsplitÚ
ValueErrorrUr4rWrrr	rErKrbrVr&r7rcÚbuildZ
statuscoder'r/)rjrgrrBZ
missing_filesÚfilenameÚstatusÚwarningrsraZwarnfpÚexcZ
confoverridesÚvalÚkeyrrQr-r-r.Ú
build_mainÄsˆ




 

rcCsNtjjtjdƒtjjtjjtdƒdƒ|dd…dgkrBt	|ƒSt
|ƒSdS)NÚÚlocaleÚsphinxrOz-M)r„rƒÚ	setlocaleÚLC_ALLZinit_consolerprrqrrlr)rjr-r-r.Úmains
r‡Ú__main__)6Ú__doc__r5rrƒr2rpr r$r"rÚtypingrrrZdocutils.utilsrZ
sphinx.localer„rrZsphinx.applicationr	Z
sphinx.errorsr
rZsphinx.utilrr
rZsphinx.util.consolerrrrZsphinx.util.docutilsrrZsphinx.util.osutilrrrÚ
BaseExceptionr/r)r4r8rdrirjrlrr‡Ú__name__Úexitr-r-r-r.Ú<module>s84_""W"