
    O&i                         d Z ddlZddlZddlZddlmZ ddlmZ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 	 ddlmZ ddlmZ n# e$ r ddlmZ ddlmZ Y nw xY w 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)StringIO)AnyDictOptional)Sphinx)handle_exception)RemovedInSphinx70Warning)color_terminalnocolor)docutils_namespacepatch_docutils)abspath)Command)	ExecError)DistutilsExecErrorc                   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    a/home/geonatureadmin/si_en_reseau/tutos/venv/lib/python3.11/site-packages/sphinx/setup_command.pyinitialize_optionszBuildDoc.initialize_optionsZ   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)r:   guessroot	_dirnames	filenamess        r;   _guess_source_dirzBuildDoc._guess_source_dirn   st    $ 	  	 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  )rA   rB   joinr-   ).0r.   r:   s     r;   
<listcomp>z-BuildDoc.finalize_options.<locals>.<listcomp>   s@     $) $) $) bgll4>7;;<$) $) $)r=   )ensure_string_listr,   rJ   announceensure_dirnamer4   r-   get_finalized_commandrA   rB   rQ   r   
build_basedoctree_dirr.   builder_target_dirs)r:   rL   s   ` r;   finalize_optionszBuildDoc.finalize_optionsw   s    	***?""4466DOMM5GHHHL)))?""oDO>!..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.   )
stacklevelr0   r1   r2   r3   r   r#   )freshenvwarningiserrorr!   r9   )	force_allzcaused by %s builder.r)   index),warningswarnr	   r
   r   r7   r   sysstdoutr0   r1   r2   r3   r   r#   rZ   r4   r,   r   r   r   rY   r*   r/   r!   r9   rL   r+   
statuscoder   r.   name	Exceptionr   stderrr    
SystemExitr5   configroot_doc
out_suffixget_outfilenamerA   symlink)
r:   status_streamconfoverridesr.   builder_target_dirappconfdirexcsrcdsts
             r;   runzBuildDoc.run   s;   <.1	> 	> 	> 	>  	III| 	'$JJMMJM(*< 	4'+|M)$< 	4'+|M)$< 	4'+|M)$: 	0%)ZM'"> 	8)-M+&= 	6(,M*%+/+C 	! 	!'G'C1/<T_#G,, 	T 	T.@.B.B 	T 	T $/!3T5E!(-*..040E+/>doW W WC III777~ T'(?#+BR(RSSST	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T  1 1 1 dC<<<x 1$Q--S01 1 1 1 11
 ? *%(>>C+--g66CJsC    3	! 	!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<   strrJ   r[   ry   rP   r=   r;   r   r      s        # #J /K  L*1 1 1O       (3    ) ) ) ),1! 1! 1! 1! 1! 1!r=   r   )!r}   rA   re   rc   ior   typingr   r   r   sphinx.applicationr   sphinx.cmd.buildr   sphinx.deprecationr	   sphinx.util.consoler
   r   sphinx.util.docutilsr   r   sphinx.util.osutilr   
setuptoolsr   setuptools.errorsr   ImportErrordistutils.cmddistutils.errorsr   r   rP   r=   r;   <module>r      s   
 
			 



        & & & & & & & & & & % % % % % % - - - - - - 7 7 7 7 7 7 7 7 7 7 7 7 7 7 C C C C C C C C & & & & & &A""""""+++++++ A A A%%%%%%@@@@@@@@A
c! c! c! c! c!w c! c! c! c! c!s   A A)(A)