o $a] @sTdZddlZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z m Z mZzddlZejrEdejvrEeddZned d ZWn eyZdZd ZYnwdd lmZddlZdd lmZmZdd lmZddlmZmZmZmZmZddl m!Z!ddl"m#Z#ededfdedfdedfdedfdedfdedfdedfded fd!ed"fd#ed$fg Z$d%d d&dd'd(ddd)Z%d*Z&ej'd+krd,Z(nd-Z(d.e)d/e)fd0d1Z*Gd2d3d3e+Z,d4e)d/e)fd5d6Z-d4e)d/e)fd7d8Z.d4e)d/e)fd9d:Z/d4e)d/e)fd;d<Z0d=e)d/e e)ge)ffd>d?Z1d4e)d/e2fd@dAZ3d4e)d/e)fdBdCZ4d4e)d/e)fdDdEZ5de0fdFe)dGe)dHe e)ge fd/ee)e2ffdIdJZ6GdKdLdLe#Z7dMe d/dfdNdOZ8d^dMe dPe2dQe2dRe)d/df dSdTZ9dMe d/e2fdUdVZ:d/ej;fdWdXZfd[d\Z?e@d]kreAe?ej=dYddSdS)_z sphinx.cmd.quickstart ~~~~~~~~~~~~~~~~~~~~~ Quickly setup documentation source to work with Sphinx. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N) OrderedDict)path)AnyCallableDictListUnionlibeditzbind ^I rl_completeTz tab: completeF) column_width)__display_version__ package_dir)__)boldcolor_terminalcolorizenocolorred) ensuredir)SphinxRendererautodocz,automatically insert docstrings from modulesdoctestz2automatically test code snippets in doctest blocks intersphinxz7link between Sphinx documentation of different projectstodoz9write "todo" entries that can be shown or hidden on buildcoveragez!checks for documentation coverageimgmathz+include math, rendered as PNG or SVG imagesmathjaxz0include math, rendered in the browser by MathJaxifconfigz7conditional inclusion of content based on config valuesviewcodez=include links to the source code of documented Python objects githubpagesz=create .nojekyll file to publish the document on GitHub pages._.rstindex)rsepdotlanguagesuffixmastermakefile batchfilez> win32rpurplepromptreturncCs&tjdkrt|ddtdSt|S)Nr*end)sysplatformprintinput)r,r57/usr/lib/python3/dist-packages/sphinx/cmd/quickstart.py term_inputLs  r7c@seZdZdZdS)ValidationErrorzRaised for validation errors.N)__name__ __module__ __qualname____doc__r5r5r5r6r8Wsr8xcCs$t|}t|sttd|S)NzPlease enter a valid path name.)r expanduserisdirr8r r=r5r5r6is_path[s   rAcCs|dkr|St|SNr.)rAr@r5r5r6is_path_or_emptybsrCcC|SNr5r@r5r5r6 allow_emptyhrFcCs|sttd|S)NzPlease enter some text.)r8r r@r5r5r6nonemptyls rHlcsdtdtffdd }|S)Nr=r-cs"|vrttdd|S)NzPlease enter one of %s., )r8r joinr@rIr5r6valsszchoice..val)str)rIrMr5rLr6choicersrOcCs$|dvr ttd|dvS)N)YYESNNOzPlease enter either 'y' or 'n'.)rPrQ)upperr8r r@r5r5r6booleanzs   rUcCs,|dddkrt|dksttd|S)Nrrz2Please enter a file suffix, e.g. '.rst' or '.txt'.)lenr8r r@r5r5r6r&s r&cCrDrEr5r@r5r5r6okrGrXtextdefault validatorc Cs |durtd||f}nt|d}trntr!tt|dd}ntt|dd}t|}|r4|s4|}z||}W |StyX}ztt dt |WYd}~qd}~ww)NTz %s [%s]: z: ) input_modeFz* ) PROMPT_PREFIX USE_LIBEDITreadlinerCOLOR_QUESTIONr7stripr8r3rrN)rYrZr[r,r=errr5r5r6 do_prompts*    rccsReZdZdeddffdd ZdedefddZded edeffd d ZZ S) QuickstartRenderer templatedirr-Ncs|pd|_tdSrB)resuper__init__)selfre __class__r5r6rgs zQuickstartRenderer.__init__ template_namecCs,t|jt|}|jrt|rdSdS)zCheck if custom template file exists. Note: Please don't use this function from extensions. It will be removed in the future without deprecation period. TF)rrKrebasenameexists)rhrktemplater5r5r6_has_custom_templatesz'QuickstartRenderer._has_custom_templatecontextcs8||rt|jt|}|||St||SrE)rorrKrerlrender_from_filerfrender)rhrkrpcustom_templaterir5r6rrs  zQuickstartRenderer.render) r9r:r;rNrgboolrorrr __classcell__r5r5rir6rds" rddc Csptttdttttdd|vr'ttttd|dntttdttddt|d<tt|ddsQtt|dd drttttd ttd tttd d t |d<|dsxt dtt|ddsQtt|dd dsQd|vrtttdttddt |d<d|vrtttdttddt |d<d|vrtttdttd|d<d|vrttd|d<d|vrtttdttdd t|d<d|vrttd |dt|d<d!|vr(tttd"ttd#d$|d!<|d!d$kr(d%|d!<d&|vr@tttd'ttd(d)t|d&<d*|vrWtttd+ttd,d-|d*<tt|d|d*|d&s|tt|dd |d*|d&rttttd.|d*|d&ttd/tttd0|d*|d*<tt|d|d*|d&s|tt|dd |d*|d&s|d1|vr ttd2g|d1<tD]\}}td3||fdt r|d1d4|qd5d6h|d1r ttd7|d1d5d8|vr$tttd9ttd:d;t |d8<d<|vr3ttd=d;t |d<<td%S)>a4Ask the user for quickstart values missing from *d*. Values are: * path: root path * sep: separate source and build dirs (bool) * dot: replacement for dot in _templates etc. * project: project name * author: author names * version: version of project * release: release of project * language: document language * suffix: source file suffix * master: master document name * extensions: extensions to use (list) * makefile: make Makefile * batchfile: make command file z,Welcome to the Sphinx %s quickstart utility.zyPlease enter values for the following settings (just press Enter to accept a default value, if one is given in brackets).rzSelected root path: %sz&Enter the root path for documentation.zRoot path for the documentationrconf.pysourcezDError: an existing conf.py has been found in the selected root path.z>sphinx-quickstart will not overwrite existing Sphinx projects.z4Please enter a new root path (or just Enter to exit)r.rVr#zYou have two options for placing the build directory for Sphinx output. Either, you use a directory "_build" within the root path, or you separate "source" and "build" directories within the root path.z+Separate source and build directories (y/n)nr$zInside the root directory, two more directories will be created; "_templates" for custom HTML templates and "_static" for custom stylesheets and other static files. You can enter another prefix (such as ".") to replace the underscore.z(Name prefix for templates and static dirr projectzIThe project name will occur in several places in the built documentation.z Project nameauthorzAuthor name(s)versiona-Sphinx has the notion of a "version" and a "release" for the software. Each version can have multiple releases. For example, for Python the version is something like 2.5 or 3.0, while the release is something like 2.5.1 or 3.0a1. If you don't need this dual structure, just set both to the same value.zProject versionreleasezProject releaser%a3If the documents are to be written in a language other than English, you can select a language here by its language code. Sphinx will then translate text that it generates into that language. For a list of supported codes, see https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language.zProject languageenNr&zThe file name suffix for source files. Commonly, this is either ".txt" or ".rst". Only files with this suffix are considered documents.zSource file suffixr!r'aOne document is special in that it is considered the top node of the "contents tree", that is, it is the root of the hierarchical structure of the documents. Normally, this is "index", but if your "index" document is a custom template, you can also set this to another filename.z-Name of your master document (without suffix)r"zKError: the master file %s has already been found in the selected root path.z7sphinx-quickstart will not overwrite the existing file.zIPlease enter a new file name, or rename the existing file and press Enter extensionszDIndicate which of the following Sphinx extensions should be enabled:z %s: %s (y/n) sphinx.ext.%szsphinx.ext.imgmathzsphinx.ext.mathjaxzZNote: imgmath and mathjax cannot be enabled at the same time. imgmath has been deselected.r(zA Makefile and a Windows command file can be generated for you so that you only have to run e.g. `make html' instead of invoking sphinx-build directly.zCreate Makefile? (y/n)yr)z"Create Windows command file? (y/n))r3rr r rcrArisfilerKrCr1exitrUrXrFr& EXTENSIONSitemsappendissubsetremove)rvname descriptionr5r5r6ask_users                $"  $"      r overwritesilentrec st|d}dvr dd<dvrdd<dd<td<td d d <d gtd ddd<tjdd<t ddrZt ddnd}t |drst dd}dd<nt |dd}t t ddddg}d |d<t |t t |ddt t |ddd?dt dt dt ddffd d! }|rtj |d"nd} | rt| stj tdd#d"} t|  } | } Wdn1swY|t |d$|| t |dd%} |d&r"d'} ttd(| || |d&n || |d)d*d+ur8d,}d-}nd.}d/}d0d+urmdrJdnd1d2<drUdnddd3<|t dd4||d5d6d+urdr{dnd1d2<drdnddd3<|t dd7||d8|rdSttttd9tttd:| dd;d0sňd6rttd<n ttd=||fttd>tdS)@z(Generate project based on values in *d*.)re mastertoctreer.mastertocmaxdepthr'root_docnowrz=project_underlinerz%YrJr{ copyrightrr#rxbuildexclude_patternsr$z Thumbs.dbz .DS_Store templatesstaticNfpathcontentnewliner-csst|s3dvrttd|t|dd|d}||WddS1s,wYdSdvrAttd|dSdS)NquietzCreating file %s.wtzutf-8)encodingrz!File %s already exists, skipping.)rrr3r openwrite)rrrfrvrr5r6 write_filems "zgenerate..write_filez conf.py_t quickstartrwr&zquickstart/master_doc.rst_tz{A custom template `master_doc.rst_t` found. It has been renamed to `root_doc.rst_t`. Please rename it on your project too.rzquickstart/root_doc.rst_t make_modeTzquickstart/Makefile.new_tzquickstart/make.bat.new_tzquickstart/Makefile_tzquickstart/make.bat_tr(rrsrcdir rbuilddirMakefile r)make.batz z:Finished: An initial directory structure has been created.zYYou should now populate your master file %s and create other documentation source files. r/zd?d@tdAd"|jdBdCdDtdEd"|jdFddGtdHdI|tdJ}tD]}|jdK|dLdM|dNtdO|dPq|jdQdRdNdStdTdU|tdV}|jdWddXdYtdZd |jd[ddXtd\d|jd]dd^dYtd_d |jd`dd^tdad|jdbdcddddYtded |jdfdgdddtdhd|tdi}|jdjdkdldmtdnd)|jdodpdSdqtdrds|S)tNz Generate required files for a Sphinx project. sphinx-quickstart is an interactive tool that asks some questions about your project and then generates a complete documentation directory and sample Makefile to be used with sphinx-build. z %(prog)s [OPTIONS] z:For more information, visit .)usageepilogrz-qz--quiet store_truerz quiet mode)actiondestrZhelpz --versionr| show_versionz %%(prog)s %s)rrr|r PROJECT_DIRr?z project root)metavarrZnargsrzStructure optionsz--sepr#z,if specified, separate source and build dirsz--no-sep store_falsez/if specified, create build dir under source dir)rrrz--dotDOTr z&replacement for dot in _templates etc.)rrZrzProject basic optionsz-pz --projectPROJECTrzz project name)rrrz-az--authorAUTHORr{z author namesz-vVERSIONr.zversion of project)rrrZrz-rz --releaseRELEASEr}zrelease of projectz-lz --languageLANGUAGEr%zdocument languagez--suffixSUFFIXr!zsource file suffixz--masterMASTERr"zmaster document namez--epubFzuse epub)rrZrzExtension optionsz--ext-%s append_constrrzenable %s extension)rconstrrz --extensionsrrzenable arbitrary extensions)rrrrzMakefile and Batchfile creationz --makefiler(Tzcreate makefilez --no-makefilezdo not create makefilez --batchfiler)zcreate batchfilez--no-batchfilezdo not create batchfilez-mz--use-make-moderz#use make-mode for Makefile/make.batz-Mz--no-use-make-modez*do not use make-mode for Makefile/make.batzProject templatingz-tz --templatedir TEMPLATEDIRrez%template directory for template filesz-dz NAME=VALUE variableszdefine a template variable)rrrr)r argparseArgumentParser add_argumentr add_argument_groupr)rparsergroupextr5r5r6 get_parsers                        rrVargvc Cs tjtjdtjtjtddt st t }z| |}Wnt y9}z |jWYd}~Sd}~wwt|}dd|D}|dg|dddD]}d|vrl|d||d|dqUzSd|vrd d h|sttd Wd Shd |r|dd|d|dt}|||}t|sttttdttdWd Snt|WnttfyttdYdSw| dgD] }z |d\}} | ||<Wqt!yttd|Yqwt"|d|j#ddS)Nr.localesphinxcSsi|] \}}|dur||qSrEr5).0kvr5r5r6 0szmain..r,rrzr{zH"quiet" is specified, but any of "project" or "author" is not specified.rV>rr{rzr|r}zHError: specified path is not a directory, or sphinx files already exist.zWsphinx-quickstart only generate into a empty directory. Please specify a new root path.z[Interrupted.]rrzInvalid template variable: %sF)rrer)$rr setlocaleLC_ALL init_consolerrrKr rrr parse_args SystemExitcodevarsrrrextendsplitrr3r DEFAULTScopyupdaterrrKeyboardInterruptEOFErrorr ValueErrorrre) rrargsrbrvrd2variablervaluer5r5r6main sh       r__main__)TFN)Br<rrrr1r collectionsrrtypingrrrrrr_parse_and_bindr^ ImportErrordocutils.utilsr sphinx.localerr r r sphinx.util.consolerrrrrsphinx.util.osutilrsphinx.util.templaterrrr]r2r`rNr7 Exceptionr8rArCrFrHrOrtrUr&rXrcrdrrrrrrintrr9rr5r5r5r6s                      2  e$U A