
    }cy                         d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZmZ ddlmZ  G d de          ZdS )zSetuptools/distutils commands to assist the building of sphinx documentation.

:author: Sebastian Wiesner <basti.wiesner@gmx.net>
    N)Command)DistutilsExecError)StringIO)AnyDict)Sphinx)handle_exception)RemovedInSphinx70Warning)color_terminalnocolor)docutils_namespacepatch_docutils)abspathc                   J    e Zd ZdZdZg dZg dZddZdefdZ	dd	Z
dd
ZdS )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
    zBuild Sphinx documentation))	fresh-envEzdiscard saved environment)	all-filesazbuild all files)zsource-dir=szSource directory)z
build-dir=NzBuild directory)zconfig-dir=cz'Location of the configuration directory)zbuilder=bz]The builder (or builders) to use. Can be a comma- or space-separated list. Defaults to "html")warning-is-errorWzTurn warning into errors)zproject=NzThe documented project's name)zversion=NzThe short X.Y version)zrelease=Nz.The full version, including alpha/beta/rc tags)ztoday=NzCHow to format the current date, used as the replacement for |today|)
link-indexiz!Link index.html to the master doc)	copyrightNzThe copyright string)pdbNzStart pdb on exception)	verbosityvz$increase verbosity (can be repeated))nitpickynz1nit-picky mode, warn about all missing references)z
keep-goingNz)With -W, keep going when getting warnings)r   r   r   r   r!   returnNc                    dx| _         | _        d| _        d | _        d | _        d| _        d| _        d| _        d| _        d| _	        d| _
        d | _        d| _        d| _        | j        j        dz
  | _        d| _        d| _        d| _        d S )NFhtml    )	fresh_env	all_filesr   
source_dir	build_dirbuilderwarning_is_errorprojectversionreleasetoday
config_dir
link_indexr   distributionverboser   	tracebackr!   
keep_going)selfs    4lib/python3.11/site-packages/sphinx/setup_command.pyinitialize_optionszBuildDoc.initialize_optionsU   s    *//#" %
#*2Q6    c                     dD ]G}t           j                            |          s"t          j        |          D ]\  }}}d|v r|c c S Ht           j        S )N)docdocszconf.py)ospathisdirwalkcurdir)r8   guessroot	_dirnames	filenamess        r9   _guess_source_dirzBuildDoc._guess_source_diri   sv    $ 	  	 E7=='' .0genn    *i	)  KKKKK   yr;   c                 &                          d            j        6                                  _                             d j        z                                  d            j         j         _         j        L                     d          }t          j	        
                    t          |j                  d           _        t          j	        
                     j        d           _         fd j        D              _        d S )Nr,   zUsing source directory %sr*   buildsphinxdoctreesc                 ^    g | ])}|t           j                            j        |          f*S  )r?   r@   joinr+   ).0r,   r8   s     r9   
<listcomp>z-BuildDoc.finalize_options.<locals>.<listcomp>   s@     $) $) $) bgll4>7;;<$) $) $)r;   )ensure_string_listr*   rH   announceensure_dirnamer2   r+   get_finalized_commandr?   r@   rO   r   
build_basedoctree_dirr,   builder_target_dirs)r8   rJ   s   ` r9   finalize_optionszBuildDoc.finalize_optionsr   s   	***? 	I"4466DOMM5GHHHL)))? 	."oDO> 	O..w77EW\\'%2B*C*CXNNDN7<<
CC$) $) $) $)<$) $) $)   r;   c                    t          j        dt          d           t                      st	                       | j        st                      }nt          j        }i }| j	        r
| j	        |d<   | j
        r
| j
        |d<   | j        r
| j        |d<   | j        r
| j        |d<   | j        r
| j        |d<   | j        r
| j        |d	<   | j        D ]|\  }}d }	 | j        p| j        }t%          |          5  t'                      5  t)          | j        | j        || j        |||| j        | j        | j        | j        
          }|                    | j                   |j        rt;          d|j        j        z            	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   nJ# t@          $ r=}tC          || |t          j"                   | j#        stI          d          |Y d }~nd }~ww xY w| j%        s4|j&        j'        |j        j(        z   }|j        )                    d          }	tU          j+        ||	           ~d S )Nz$setup.py build_sphinx is deprecated.   )
stacklevelr.   r/   r0   r1   r   r!   )freshenvwarningiserrorr   r7   )	force_allzcaused by %s builder.r'   index),warningswarnr
   r   r   r5   r   sysstdoutr.   r/   r0   r1   r   r!   rX   r2   r*   r   r   r   rW   r(   r-   r   r7   rJ   r)   
statuscoder   r,   name	Exceptionr	   stderrr   
SystemExitr3   configroot_doc
out_suffixget_outfilenamer?   symlink)
r8   status_streamconfoverridesr,   builder_target_dirappconfdirexcsrcdsts
             r9   runzBuildDoc.run   sD   <.1	> 	> 	> 	>  	III| 	'$JJMMJM(*< 	4'+|M)$< 	4'+|M)$< 	4'+|M)$: 	0%)ZM'"> 	8)-M+&= 	6(,M*%+/+C 	! 	!'G'C1/<T_#G,, 
H 
H.@.B.B 
H 
H $/!3T5E!(-*..040E+/>doW W WC III777~ H03ck6FFH H HH
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H  1 1 1 dC<<<x 1$Q--S01 1 1 1 11
 ? *%(>>C+--g66CJsC    5	! 	!sa   F+0F?A<F<FFFFFF+F#	#F+&F#	'F++
G253G--G2)r#   N)__name__
__module____qualname____doc__descriptionuser_optionsboolean_optionsr:   strrH   rY   rw   rN   r;   r9   r   r      s        # #J /K  L*1 1 1O       (3    ) ) ) ),2! 2! 2! 2! 2! 2!r;   r   )r{   r?   rc   ra   distutils.cmdr   distutils.errorsr   ior   typingr   r   sphinx.applicationr   sphinx.cmd.buildr	   sphinx.deprecationr
   sphinx.util.consoler   r   sphinx.util.docutilsr   r   sphinx.util.osutilr   r   rN   r;   r9   <module>r      s0   
 
			 



  ! ! ! ! ! ! / / / / / /               % % % % % % - - - - - - 7 7 7 7 7 7 7 7 7 7 7 7 7 7 C C C C C C C C & & & & & &d! d! d! d! d!w d! d! d! d! d!r;   