
    }c,                         d Z ddlZddlmZ ddlmZmZmZm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mZ  ej        e          Zg d	Z G d
 d          ZdS )z1Utility function and classes for Sphinx projects.    N)glob)DictListOptionalSet)__)get_matching_filesloggingpath_stabilize)compile_matchers)SEPrelpath)z**/_sourcesz.#*z**/.#*z
*.lproj/**c                       e Zd ZdZdedeeef         ddfdZddZg fd	ee         de	e         fd
Z
dedee         fdZddededefdZdS )Projectz;A project is the source code set of the Sphinx document(s).srcdirsource_suffixreturnNc                 H    || _         || _        t                      | _        d S )N)r   r   setdocnames)selfr   r   s      .lib/python3.11/site-packages/sphinx/project.py__init__zProject.__init__   s$     + #&%%    otherc                     |j         | _         dS )z!Take over a result of last build.N)r   )r   r   s     r   restorezProject.restore   s    r   exclude_pathsc           	          t                       _        t          |t          z             }t	           j        |          D ].}                     |          }|r| j        v rt          j        	                     j        |          dz   } fdt          |          D             }t                              t          d          ||                     |          d           t          j        t          j        	                     j        |          t          j                  r j                            |           t                              t          d          |           0 j        S )zbFind all document files in the source directory and put them in
        :attr:`docnames`.
        z.*c                 :    g | ]}t          |j                  S  )r   r   ).0fr   s     r   
<listcomp>z$Project.discover.<locals>.<listcomp>,   s%    LLLWQ44LLLr   zDmultiple files found for the document "%s": %r
Use %r for the build.T)oncezdocument not readable. Ignored.)location)r   r   r   EXCLUDE_PATHSr	   r   path2docospathjoinr   loggerwarningr   doc2pathaccessR_OKadd)r   r   excludesfilenamedocnamepatternfiless   `      r   discoverzProject.discover!   s\    #MM$ABB*4;AA 	\ 	\HmmH--G 
\dm+ 	\ gll4;@@4GGLLLLd7mmLLLENN2 '> $? $?#*E4==3I3IPT # V V V V Yrw||DKBBBGLL \M%%g....NN2&G#H#HSZN[[[}r   r3   c                     |                     | j                  rt          || j                  }| j        D ]@}|                    |          r)t          |          }|dt          |                    c S AdS )zReturn the docname for the filename if the file is a document.

        *filename* should be absolute or relative to the source directory.
        N)
startswithr   r   r   endswithr   len)r   r3   suffixs      r   r(   zProject.path2doc7   s    
 t{++ 	6x55H( 	/ 	/F  (( /)(33#f++..../
 tr   Tr4   basedirc                 H   |                     t          t          j        j                  }t          j                            | j        |          }| j        D ]&}t          j                            ||z             r n't          | j                  d         }|r||z   S ||z   S )zReturn the filename for the document name.

        If *basedir* is True, return as an absolute path.
        Else, return as a relative path to the source directory.
        r   )
replacer   r)   r*   sepr+   r   r   isfilelist)r   r4   r=   basenamer<   s        r   r.   zProject.doc2pathF   s     //#rw{337<<W55( 	1 	1Fw~~h/00  $,--a0F 	$f$$V##r   )r   r   r   N)T)__name__
__module____qualname____doc__strr   r   r   r   r   r7   r   r(   boolr.   r!   r   r   r   r      s        EE(s (4S> (d ( ( ( (' ' ' ' 35  d3i S    , #    $ $ $d $c $ $ $ $ $ $r   r   )rG   r)   r   typingr   r   r   r   sphinx.localer   sphinx.utilr	   r
   r   sphinx.util.matchingr   sphinx.util.osutilr   r   	getLoggerrD   r,   r'   r   r!   r   r   <module>rP      s    7 7 				       , , , , , , , , , , , ,       C C C C C C C C C C 1 1 1 1 1 1 + + + + + + + +		8	$	$>>>H$ H$ H$ H$ H$ H$ H$ H$ H$ H$r   