o $a0 @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZddlZddlmZmZddlmZddlmZddlmZdd lmZmZmZdd lmZmZmZm Z dd l!m"Z"m#Z#ej$fd ed e de%de ddf ddZ&de'de(fddZ)dej*fddZ+ej,ddfde e'de(fddZ-ej,ddfde e'de(fddZ.ej,ddfde e'de(fddZ/e0d kre1e/ej,dddSdS)!z sphinx.cmd.build ~~~~~~~~~~~~~~~~ Build documentation from a provided source. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)IOAnyList) SystemMessage)__display_version__ package_dir)Sphinx) SphinxError)__)Teeformat_exception_cut_framessave_traceback)color_terminalnocolorred terminal_safe)docutils_namespacepatch_docutilsappargs exceptionstderrreturncCs&t|tjrdS|jr$tttd|dtt t ddSt|d|j s/|jr:td|t|dt|t rIttd|ddSt|tretttd|dtt|jd|ddSt|trttd|j|dtt||ddSt|trtttd|dttt||dt|}tttd ||ddSt|trd t|vrtttd |dttt||dt|dttd |dtd |ddStttd|dtt|dt|}tttd ||dttd|dttd|ddS)Nz5Exception occurred while building, starting debugger:)filez 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:zThis 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 . Thanks!) isinstancebdbBdbQuitpdbprintrr traceback print_exc post_mortemsysexc_info verbosityKeyboardInterruptrrrr categorystr UnicodeErrorr RuntimeErrorr rstrip)rrrrtbpathr-2/usr/lib/python3/dist-packages/sphinx/cmd/build.pyhandle_exception!sf               r/valuecCs2|dkrtSt|}|dkrttd|S)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 number)multiprocessing cpu_countintargparseArgumentTypeErrorr )r0jobsr-r-r. jobs_argumentUs r8cCsxtjdtdtdd}|jddddtd |jd td d |jd tdd |jddtdd|td}|jddddtdd|jdddtdd|jddd td!d|jd"d#d$td%d&|jd'd(d)td*td+d,|d-}|jd.d#d/td0d&|jd1dd2td3d|jd4d5d6d7gtd8d9|jd:d;d6dd?d6d@gtdAd9|jdBddCtdDd|tdE}|jdFdGdHdItdJdK|jdLddMtdNd|jdOddPtdQd|jdRdSdTdUtdVdW|jdXdYdZdSd[td\d]|jd^d_d`tdad&|jdbddctddd|jdeddftdgd|jdhdditdjd|jdkddltdmd|S)nNz5%(prog)s [OPTIONS] SOURCEDIR OUTPUTDIR [FILENAMES...]z:For more information, visit .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. )usageepilog descriptionz --versionversion show_versionz %%(prog)s %s)actiondestr< 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)nargsrAzgeneral optionsz-bBUILDERbuilderhtmlzbuilder to use (default: html))metavarr?defaultrAz-a store_true force_allz;write all files (default: only write new and changed files))r>r?rAz-Efreshenvz4don't use a saved environment, always read all filesz-dPATH doctreedirzPpath for the cached environment and doctree files (default: OUTPUTDIR/.doctrees))rIr?rAz-jNr7z`build in parallel with N processes where possible (special value "auto" will set N to cpu-count))rIrJtyper?rAzbuild configuration optionsz-cconfdirzOpath where configuration file (conf.py) is located (default: same as SOURCEDIR)z-Cnoconfigz*use no config file at all, only -D optionsz-Dz setting=valueappenddefinez(override a setting in configuration file)rIr>r?rJrAz-Az name=value htmldefinez pass a value into HTML templatesz-tTAGtagsz*define tag: include "only" blocks with TAGz-nnitpickyz1nit-picky mode, warn about all missing referenceszconsole output optionsz-vcountr%rz$increase verbosity (can be repeated))r>r?rJrAz-qquietz,no output on stdout, just warnings on stderrz-Q really_quietz#no output at all, not even warningsz--color store_constyesr1z-do emit colored output (default: auto-detect))r>constrJrAz-Nz --no-colorcolornoz1do not emit colored output (default: auto-detect))r?r>r`rAz-wFILEwarnfilez)write warnings (and errors) to given filez-Wwarningiserrorzturn warnings into errorsz --keep-going keep_goingz)with -W, keep going when getting warningsz-Tr z show full traceback on exceptionz-Przrun Pdb on exception)r5ArgumentParserr add_argumentradd_argument_groupr8)parsergroupr-r-r. get_parseres                      rlrQargvcCsddlm}||ddS)zSphinx build "make mode" entry.r) make_moderQN) sphinx.cmdrn run_make_mode)rmrnr-r-r. make_mains rqcCst}||}|jrd|_n|js|j|_|js"tj|j d|_|j }g}|D] }tj |s6| |q)|rB| td||jrN|rN| td|jdks[|jdkr^ts^ttj}tj}tj}|jrld}|jrsd}}|r|jrzt|jd} Wnty} z| td|j| fWYd} ~ nd} ~ wwt|| }|}i} |jD]!} z | d d \} } Wnty| td Ynw| | | <q|jD]2} z | d \} } Wnty| td Ynwzt | } Wn tyYnw| | d | <q|j!r d| d<d}zc|jp|j}t"|Lt#6t$|j|j|j |j|j%| |||j&|j'|j(|j)|j*|j+}|,|j||j-WdWdWS1sWwYWdWdS1siwYWdStt.fy} zt/||| |WYd} ~ dSd} ~ ww)z'Sphinx build "main" command-line entry.Nz .doctreeszcannot find files %rz&cannot combine -a option and filenamesrbr1wzcannot open warning file %r: %s=rQz1-D option argument must be in the form name=valuez1-A option argument must be in the form name=valuezhtml_context.%sTrZr)0rl parse_argsrTrSr@rOospathjoinrBrCisfilerUerrorr rLrarrr#stdoutrr\r]rdopen Exceptionr rVsplit ValueErrorrWr4rZrrrrGrMrerYr%r7rfbuild statuscoder&r/)rmrjrrC missing_filesfilenamestatuswarningrywarnfpexc confoverridesvalkeyrrSr-r-r. build_mains                \rcCsJtjtjdtjtjtdd|dddgkr!t |St |S)NlocalesphinxrQz-M) rr setlocaleLC_ALL init_consolerurvrwrrqr)rmr-r-r.mains r__main__)2__doc__r5rrr2rurr#r typingrrrdocutils.utilsr sphinx.localerrrsphinx.applicationr sphinx.errorsr r sphinx.utilr r r sphinx.util.consolerrrrsphinx.util.docutilsrrr BaseExceptionr/r(r4r8rgrlrmrqrr__name__exitr-r-r-r.s8     $4$_$$U