o $ap@sdZddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z ddlmZdd lmZmZdd lmZmZdd lmZGd d d eZdS)a? sphinx.setup_command ~~~~~~~~~~~~~~~~~~~~ Setuptools/distutils commands to assist the building of sphinx documentation. :author: Sebastian Wiesner :contact: basti.wiesner@gmx.net :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)Command)DistutilsExecError)StringIO)AnyDict)Sphinx)handle_exception)color_terminalnocolor)docutils_namespacepatch_docutils)abspathc@sPeZdZdZdZgdZgdZdddZdefd d Z dd d Z dd dZ dS)BuildDoca9 Distutils command to build Sphinx documentation. The Sphinx build can then be triggered from distutils, and some Sphinx options can be set in ``setup.py`` or ``setup.cfg`` instead of Sphinx's own configuration file. For instance, from `setup.py`:: # this is only necessary when not using setuptools/distribute from sphinx.setup_command import BuildDoc cmdclass = {'build_sphinx': BuildDoc} name = 'My project' version = '1.2' release = '1.2.0' setup( name=name, author='Bernard Montgomery', version=release, cmdclass=cmdclass, # these are optional and override conf.py settings command_options={ 'build_sphinx': { 'project': ('setup.py', name), 'version': ('setup.py', version), 'release': ('setup.py', release)}}, ) Or add this section in ``setup.cfg``:: [build_sphinx] project = 'My project' version = 1.2 release = 1.2.0 zBuild Sphinx documentation)) fresh-envEzdiscard saved environment) all-filesazbuild all files)z source-dir=szSource directory)z build-dir=NzBuild directory)z config-dir=cz'Location of the configuration directory)zbuilder=bz]The builder (or builders) to use. Can be a comma- or space-separated list. Defaults to "html")warning-is-errorWzTurn warning into errors)zproject=NzThe documented project's name)zversion=NzThe short X.Y version)zrelease=Nz.The full version, including alpha/beta/rc tags)ztoday=NzCHow to format the current date, used as the replacement for |today|) link-indexiz!Link index.html to the master doc) copyrightNzThe copyright string)pdbNzStart pdb on exception) verbosityvz$increase verbosity (can be repeated))nitpickynz1nit-picky mode, warn about all missing references)z keep-goingNz)With -W, keep going when getting warnings)rrrrrreturnNcCsxd|_|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ |jjd|_d|_d|_d|_dS)NFhtml) fresh_env all_filesr source_dir build_dirbuilderwarning_is_errorprojectversionreleasetoday config_dir link_indexr distributionverboser tracebackr keep_goingselfr66/usr/lib/python3/dist-packages/sphinx/setup_command.pyinitialize_options[s"  zBuildDoc.initialize_optionscCsHdD]}tj|s qt|D]\}}}d|vr|SqqtjS)N)docdocszconf.py)ospathisdirwalkcurdir)r5guessrootdirnames filenamesr6r6r7_guess_source_diros  zBuildDoc._guess_source_dircsdjdur_djdjdur%j_jdur:d}tj t |j d_tj jd_ fddjD_dS) Nr(zUsing source directory %sr&buildsphinxdoctreescs g|] }|tjj|fqSr6)r;r<joinr').0r(r4r6r7 sz-BuildDoc.finalize_options..)ensure_string_listr&rDannounceensure_dirnamer.r'get_finalized_commandr;r<rHr build_base doctree_dirr(builder_target_dirs)r5rEr6r4r7finalize_optionsxs         zBuildDoc.finalize_optionsc Cstst|js t}ntj}i}|jr|j|d<|jr"|j|d<|jr*|j|d<|j r2|j |d<|j r:|j |d<|j rB|j |d<|j D]\}}d}zW|j pQ|j}t|Ct0t|j|j ||j||||j|j|j|jd }|j|jd|jrtd |jjWdn1swYWdn1swYWn"ty}zt|||tj|j st!d |WYd}~nd}~ww|j"sqE|j#j$|jj%}|j&d } t'(|| qEdS) Nr*r+r,r-rr)freshenvwarningiserrorrr3) force_allzcaused by %s builder.r#index))r r r1rsysstdoutr*r+r,r-rrrQr.r&r r rrPr$r)rr3rEr% statuscoderr(name Exceptionrstderrr SystemExitr/configroot_doc out_suffixget_outfilenamer;symlink) r5 status_stream confoverridesr(builder_target_dirappconfdirexcsrcdstr6r6r7runsj             z BuildDoc.run)r N) __name__ __module__ __qualname____doc__ description user_optionsboolean_optionsr8strrDrRrkr6r6r6r7rs%  r)ror;rW distutils.cmdrdistutils.errorsriortypingrrsphinx.applicationrsphinx.cmd.buildrsphinx.util.consoler r sphinx.util.docutilsr r sphinx.util.osutilr rr6r6r6r7s