3

T'ícâ\ã@s.dZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZy:ddlZejrŠdejkrŠejdƒdZnejd	ƒd
ZWnek
r¶dZd
ZYnXddlmZddlZddlmZmZdd
lmZddlmZmZmZmZmZddl m!Z!ddl"m#Z#ededƒfdedƒfdedƒfdedƒfdedƒfdedƒfdedƒfded ƒfd!ed"ƒfd#ed$ƒfg
ƒZ$d%d
d&dd'd(ddd)œZ%d*Z&ej'd+kr´d,Z(nd-Z(e)e)d.œd/d0„Z*Gd1d2„d2e+ƒZ,e)e)d3œd4d5„Z-e)e)d3œd6d7„Z.e)e)d3œd8d9„Z/e)e)d3œd:d;„Z0e)ee)ge)fd<œd=d>„Z1e)e2d3œd?d@„Z3e)e)d3œdAdB„Z4e)e)d3œdCdD„Z5de0fe)e)ee)ge
fee)e2fdEœdFdG„Z6GdHdI„dIe#ƒZ7eddJœdKdL„Z8dZee2e2e)ddMœdNdO„Z9ee2dJœdPdQ„Z:ej;dRœdSdT„Z<ej=dUd…fe
e)e>dVœdWdX„Z?e@dYkr*ejAe?ej=dUd…ƒƒdS)[z7Quickly setup documentation source to work with Sphinx.éN)ÚOrderedDict)Úpath)ÚAnyÚCallableÚDictÚListÚUnionÚlibeditzbind ^I rl_completeTz
tab: completeF)Úcolumn_width)Ú__display_version__Úpackage_dir)Ú__)ÚboldÚcolor_terminalÚcolorizeÚnocolorÚred)Ú	ensuredir)ÚSphinxRendererZautodocz,automatically insert docstrings from modulesÚdoctestz2automatically test code snippets in doctest blocksZintersphinxz7link between Sphinx documentation of different projectsÚtodoz9write "todo" entries that can be shown or hidden on buildZcoveragez!checks for documentation coverageZimgmathz+include math, rendered as PNG or SVG imagesZmathjaxz0include math, rendered in the browser by MathJaxÚifconfigz7conditional inclusion of content based on config valuesZviewcodez=include links to the source code of documented Python objectsZgithubpagesz=create .nojekyll file to publish the document on GitHub pagesÚ.Ú_z.rstÚindex)rÚsepÚdotÚlanguageÚsuffixÚmasterÚmakefileÚ	batchfilez> Úwin32rZpurple)ÚpromptÚreturncCs*tjdkrt|ddtdƒSt|ƒSdS)Nr"Ú)Úend)ÚsysÚplatformÚprintÚinput)r#©r+ú7/tmp/pip-build-gk9425m9/sphinx/sphinx/cmd/quickstart.pyÚ
term_inputDs
r-c@seZdZdZdS)ÚValidationErrorzRaised for validation errors.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r+r+r+r,r.Osr.)Úxr$cCs$tj|ƒ}tj|ƒs ttdƒƒ‚|S)NzPlease enter a valid path name.)rÚ
expanduserÚisdirr.r
)r3r+r+r,Úis_pathSs

r6cCs|dkr|St|ƒS)Nr%)r6)r3r+r+r,Úis_path_or_emptyZsr7cCs|S)Nr+)r3r+r+r,Úallow_empty`sr8cCs|sttdƒƒ‚|S)NzPlease enter some text.)r.r
)r3r+r+r,Únonemptydsr9)Úlr$csttdœ‡fdd„}|S)N)r3r$cs"|ˆkrttdƒdjˆƒƒ‚|S)NzPlease enter one of %s.z, )r.r
Újoin)r3)r:r+r,Úvalkszchoice.<locals>.val)Ústr)r:r<r+)r:r,Úchoicejsr>cCs$|jƒdkrttdƒƒ‚|jƒdkS)NÚYÚYESÚNÚNOzPlease enter either 'y' or 'n'.)r?r@rArB)r?r@)Úupperr.r
)r3r+r+r,ÚbooleanrsrDcCs,|dd…dkot|ƒdks(ttdƒƒ‚|S)Nrérz2Please enter a file suffix, e.g. '.rst' or '.txt'.)Úlenr.r
)r3r+r+r,rxsrcCs|S)Nr+)r3r+r+r,Úok~srG)ÚtextÚdefaultÚ	validatorr$cCsºx´|dk	rtd||f}nt|d}tr.n"trBtt|dd}ntt|dd}t|ƒjƒ}|rj|rj|}y||ƒ}Wn8tk
r®}ztt	dt
|ƒƒƒwWYdd}~XnXPqW|S)Nz	%s [%s]: z: T)Z
input_modeFz* )Ú
PROMPT_PREFIXÚUSE_LIBEDITÚreadlinerÚCOLOR_QUESTIONr-Ústripr.r)rr=)rHrIrJr#r3Úerrr+r+r,Ú	do_prompt‚s&
rQcsJeZdZeddœ‡fdd„Zeedœdd„Zeeedœ‡fd	d
„Z‡Z	S)ÚQuickstartRendererN)Útemplatedirr$cs|pd|_tƒjƒdS)Nr%)rSÚsuperÚ__init__)ÚselfrS)Ú	__class__r+r,rUŸs
zQuickstartRenderer.__init__)Ú
template_namer$cCs0tj|jtj|ƒƒ}|jr(tj|ƒr(dSdSdS)z¸Check if custom template file exists.

        Note: Please don't use this function from extensions.
              It will be removed in the future without deprecation period.
        TFN)rr;rSÚbasenameÚexists)rVrXÚtemplater+r+r,Ú_has_custom_template£sz'QuickstartRenderer._has_custom_template)rXÚcontextr$cs<|j|ƒr*tj|jtj|ƒƒ}|j||ƒStƒj||ƒSdS)N)r\rr;rSrYZrender_from_filerTÚrender)rVrXr]Zcustom_template)rWr+r,r^¯s
zQuickstartRenderer.render)
r/r0r1r=rUÚboolr\rr^Ú
__classcell__r+r+)rWr,rRžsrR)Údr$cCstttdƒƒtƒtƒttdƒƒd|krNtƒtttdƒƒ|dƒn&tƒttdƒƒttdƒdtƒ|d<x€tjtj|ddƒƒs¤tjtj|dd	dƒƒrôtƒtttd
ƒƒƒttdƒƒtƒttdƒd
t	ƒ|d<|dsvt
jdƒqvWd|kr&tƒttdƒƒttdƒdtƒ|d<d|krVtƒttdƒƒttdƒdt
ƒ|d<d|kr‚tƒttdƒƒttdƒƒ|d<d|krœttdƒƒ|d<d|krÌtƒttdƒƒttdƒd
tƒ|d<d|krîttd ƒ|dtƒ|d<d!|kr2tƒttd"ƒƒttd#ƒd$ƒ|d!<|d!d$kr2d%|d!<d&|krbtƒttd'ƒƒttd(ƒd)tƒ|d&<d*|krtƒttd+ƒƒttd,ƒd-ƒ|d*<xžtjtj|d|d*|d&ƒƒsÜtjtj|dd	|d*|d&ƒƒr.tƒtttd.ƒ|d*|d&ƒƒttd/ƒƒtƒttd0ƒ|d*ƒ|d*<q’Wd1|kr¼ttd2ƒƒg|d1<x>tjƒD]2\}}td3||fdtƒrX|d1jd4|ƒqXWd5d6hj|d1ƒr¼ttd7ƒƒ|d1jd5ƒd8|krìtƒttd9ƒƒttd:ƒd;tƒ|d8<d<|kr
ttd=ƒd;tƒ|d<<tƒd%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 documentationrzconf.pyÚsourcezDError: 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%rErzÉYou 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)ÚnrzêInside 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 nameÚauthorzAuthor 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 versionÚreleasezProject releasera3If 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 languageÚenNrz‡The file name suffix for source files. Commonly, this is either ".txt"
or ".rst". Only files with this suffix are considered documents.zSource file suffixz.rstraOne 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)rzKError: 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)z
sphinx.ext.%szsphinx.ext.imgmathzsphinx.ext.mathjaxzZNote: imgmath and mathjax cannot be enabled at the same time. imgmath has been deselected.r z—A 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))r)rr
rrQr6rÚisfiler;r7r'ÚexitrDrGr8rÚ
EXTENSIONSÚitemsÚappendÚissubsetÚremove)raÚnameÚdescriptionr+r+r,Úask_user·sœ








&&



rt)raÚ	overwriteÚsilentrSr$cs²t|d}dˆkrdˆd<dˆkr*dˆd<ˆdˆd<tjƒˆd<tˆd	ƒd
ˆd<ˆjdgƒtjd
ƒdˆdˆd<tjjˆdƒˆd<t	ˆdƒˆdr´tj
ˆddƒnˆd}t	|ƒˆdrætj
ˆddƒ}dˆd<n:tj
|ˆddƒ}ttˆddddgƒ}dj
|ƒˆd<t	|ƒt	tj
|ˆddƒƒt	tj
|ˆddƒƒd<t
t
t
ddœ‡‡fdd„
}|rˆtjj
|dƒnd}	|	s¢tj|	ƒr´tjj
tdd dƒ}	t|	ƒ}
|
jƒ}WdQRX|tj
|d!ƒ|j|ˆƒƒtj
|ˆdˆd"ƒ}|jd#ƒr4d$}
ttd%|
ƒƒ|||jd#ˆƒƒn|||jd&ˆƒƒˆjd'ƒd(kr`d)}d*}nd+}d,}ˆd-d(krʈdr„dnd.ˆd/<ˆdršdn
ˆddˆd0<|tj
ˆdd1ƒ|j|ˆƒd2ƒˆd3d(kr,ˆdrædnd.ˆd/<ˆdrüdn
ˆddˆd0<|tj
ˆdd4ƒ|j|ˆƒd5ƒ|r6dStƒtttd6ƒƒƒtƒttd7ƒ|dd8ˆd-szˆd3rˆttd9ƒƒnttd:ƒ||fƒttd;ƒƒtƒdS)=z(Generate project based on values in *d*.)rSZ
mastertoctreer%ZmastertocmaxdepthérZroot_docÚnowrdú=Zproject_underlineriz%Yz, reÚ	copyrightrrrbÚbuildÚexclude_patternsrz	Thumbs.dbz	.DS_StoreÚ	templatesÚstaticN)ÚfpathÚcontentÚnewliner$c	slˆstj|ƒrPdˆkr(ttdƒ|ƒt|dd|d}|j|ƒWdQRXndˆkrhttdƒ|ƒdS)NÚquietzCreating file %s.Úwtzutf-8)Úencodingrz!File %s already exists, skipping.)rrkr)r
ÚopenÚwrite)rr€rÚf)rarur+r,Ú
write_fileeszgenerate.<locals>.write_filez	conf.py_tZ
quickstartzconf.pyrzquickstart/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 rZrsrcdirZ	rbuilddirÚMakefileÚ
r!zmake.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&z<Use the Makefile to build the docs, like so:
   make builderzYUse the sphinx-build command to build the docs, like so:
   sphinx-build -b builder %s %szPwhere "builder" is one of the supported builders, e.g. html, latex or linkcheck.)N)rRÚtimeÚasctimer
Ú
setdefaultÚstrftimeÚosrÚabspathrr;ÚmapÚreprr=rkrr…ÚreadZ
render_stringr\r)rr^Úgetrr
)rarurvrSr[ÚsrcdirZbuilddirr|rˆZ	conf_pathr‡Z	conf_textZ
masterfileÚmsgZmakefile_templateZbatchfile_templater+)rarur,ÚgenerateAs„
 




r˜cCs¶|d}tj|ƒsdStj|ƒs$dSddhttj|ƒƒ@r>dS|drptjjd|ƒ}tj|ƒsbdStj|ƒspdSd|d	d
|d	d|d|d
g}t|ƒttj|ƒƒ@r²dSdS)NrTFrŠzmake.batrrbzconf.pyrr~r}rr)rrZr5ÚsetrÚlistdirr;)raÚdirZreserved_namesr+r+r,Ú	valid_dir¦s(





rœ)r$cCs¶tdƒ}tjdtdƒ|d}|jdddddtd	ƒd
|jddd
dtd|jddddtdƒd|jtdƒƒ}|jddddtdƒd
|jdddtdƒd|jddd td!ƒd"|jtd#ƒƒ}|jd$d%d&d'td(ƒd)|jd*d+d,d-td.ƒd)|jd/d0dd1td2ƒd3|jd4d5d6d7td8ƒd)|jd9d:d;d<td=ƒd)|jd>d?d@tdAƒd"|jdBdCdDtdEƒd"|jdFddGtdHƒdI|jtdJƒƒ}x2tD]*}|jdK|dLdM|dNtdOƒ|dPq’W|jdQdRdNdStdTƒdU|jtdVƒƒ}|jdWddXdYtdZƒd
|jd[ddXtd\ƒd|jd]dd^dYtd_ƒd
|jd`dd^tdaƒd|jdbdcddddYtdeƒd
|jdfdgdddtdhƒd|jtdiƒƒ}|jdjdkdldmtdnƒd)|jdodpdSdqtdrƒds|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] <PROJECT_DIR>z:For more information, visit <https://www.sphinx-doc.org/>.)ÚusageÚepilogrsz-qz--quietÚ
store_truer‚z
quiet mode)ÚactionÚdestrIÚhelpz	--versionrfZshow_versionz%%(prog)s %s)r r¡rfrZPROJECT_DIRrú?zproject root)ÚmetavarrIÚnargsr¢zStructure optionsz--seprz,if specified, separate source and build dirsz--no-sepÚstore_falsez/if specified, create build dir under source dir)r r¡r¢z--dotÚDOTrz&replacement for dot in _templates etc.)r¤rIr¢zProject basic optionsz-pz	--projectZPROJECTrdzproject name)r¤r¡r¢z-az--authorZAUTHORrezauthor namesz-vÚVERSIONr%zversion of project)r¤r¡rIr¢z-rz	--releaseZRELEASErgzrelease of projectz-lz
--languageÚLANGUAGErzdocument languagez--suffixZSUFFIXz.rstzsource file suffixz--masterZMASTERrzmaster document namez--epubFzuse epub)r rIr¢zExtension optionsz--ext-%sÚappend_constz
sphinx.ext.%srizenable %s extension)r Úconstr¡r¢z--extensionsrmrozenable arbitrary extensions)r¤r¡r r¢zMakefile and Batchfile creationz
--makefiler Tzcreate makefilez
--no-makefilezdo not create makefilez--batchfiler!zcreate batchfilez--no-batchfilezdo not create batchfilez-mz--use-make-moder‰z#use make-mode for Makefile/make.batz-Mz--no-use-make-modez*do not use make-mode for Makefile/make.batzProject templatingz-tz
--templatedirZTEMPLATEDIRrSz%template directory for template filesz-dz
NAME=VALUEÚ	variableszdefine a template variable)r¤r r¡r¢)r
ÚargparseÚArgumentParserÚadd_argumentrÚadd_argument_grouprm)rsÚparserÚgroupÚextr+r+r,Ú
get_parserÃsˆ












r´rE)Úargvr$c
"Cstjjtjdƒtjjtjjtdƒdƒt	ƒs4t
ƒtƒ}y|j|ƒ}Wn"t
k
rj}z|jSd}~XnXt|ƒ}dd„|jƒDƒ}|jdgƒxB|ddd…D].}d|kr¤|dj|ƒ|dj|jdƒƒq¤Wy¬d|krd	d
hj|ƒsttdƒƒdSdd	d
hj|ƒrx|jd
dƒ|jd|d
ƒtjƒ}|j|ƒ|}t|ƒs€tƒtttdƒƒƒttdƒƒdSnt|ƒWn(ttfk
rªtƒtdƒdSXxX|j dgƒD]H}y|jdƒ\}}	|	||<Wn&t!k
rþttdƒ|ƒYnXqºWt"|d|j#ddS)Nr%ÚlocaleÚsphinxcSsi|]\}}|dk	r||“qS)Nr+)Ú.0ÚkÚvr+r+r,ú
<dictcomp>(szmain.<locals>.<dictcomp>riú,r‚rdrezH"quiet" is specified, but any of "project" or "author" is not specified.rErfrgzHError: 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.]é‚r¬ryzInvalid template variable: %sF)rurSr)$r·r¶Ú	setlocaleÚLC_ALLZinit_consolerrr;rrrr´Ú
parse_argsÚ
SystemExitÚcodeÚvarsrnrŽrqÚextendÚsplitrpr)r
ÚDEFAULTSÚcopyÚupdaterœrrtÚKeyboardInterruptÚEOFErrorr•Ú
ValueErrorr˜rS)
rµr±ÚargsrPrar³Zd2ÚvariablerrÚvaluer+r+r,ÚmainsZ


rÏÚ__main__)TFN)Br2r­r¶rr'rŒÚcollectionsrrÚtypingrrrrrrMÚparse_and_bindrLÚImportErrorZdocutils.utilsr
Z
sphinx.localer·rrr
Zsphinx.util.consolerrrrrZsphinx.util.osutilrZsphinx.util.templaterrmrÆrKr(rNr=r-Ú	Exceptionr.r6r7r8r9r>r_rDrrGrQrRrtr˜rœr®r´rµÚintrÏr/rlr+r+r+r,Ú<module>sŠ











,
dU"A