
    -Ph                        d Z ddlm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 ddlmZ dd	lmZ dd
lmZ erddlmZ  ej        e          Zg dZ G d d          ZdS )z1Utility function and classes for Sphinx projects.    )annotationsN)Path)TYPE_CHECKING)__)logging)_StrPath)get_matching_files)path_stabilize)Iterable)z**/_sourcesz.#*z**/.#*z
*.lproj/**c                  >    e Zd ZdZddZdd
Z	 dddZddZd dZdS )!Projectz;A project is the source code set of the Sphinx document(s).srcdirstr | os.PathLike[str]source_suffixIterable[str]returnNonec                    t          |          | _        t          |          | _        t	          t          | j                  d          | _        t                      | _        i | _	        i | _
        d S )N )r   r   tupler   nextiter_first_source_suffixsetdocnames_path_to_docname_docname_to_path)selfr   r   s      N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/project.py__init__zProject.__init__   sg     v&& #=11$(d.@)A)A2$F$F! #&%% 2413    otherc                N    |j         | _         |j        | _        |j        | _        dS )z!Take over a result of last build.N)r   r   r   )r   r"   s     r   restorezProject.restore+   s'     % 6 % 6r!    z**exclude_pathsinclude_pathsset[str]c           
     N     j                                           j                                          j                                         t	           j        |g |t                    D ]2}                     |          x}r| j         v r~ fd j                            | d          D             }t          
                    t          d          |d                    |                               |d          d           t          j         j        |z  t          j                  r? j                             |           t%          |          }| j        |<   | j        |<   t          
                    t          d          ||	           4 j         S )
zbFind all document files in the source directory and put them in
        :attr:`docnames`.
        c                ^    g | ])}t          |                    j                            *S r%   )strrelative_tor   ).0fr   s     r   
<listcomp>z$Project.discover.<locals>.<listcomp>B   s?        AMM$+6677  r!   z.*zDmultiple files found for the document "%s": %s
Use %r for the build.z, T)absolute)oncezIgnored unreadable document %r.)location)r   clearr   r   r	   r   EXCLUDE_PATHSpath2docglobloggerwarningr   joindoc2pathosaccessR_OKaddr   )r   r'   r(   filenamedocnamefilespaths   `      r   discoverzProject.discover1   s    	##%%%##%%%*K,m,m,
 
 	 	H
 --111w dm++   !%!1!1W...!A!A  E NN4   		%((g==! # 	 	 	 	 Yt{X5rw?? 
M%%g...>>D29D)$/59D)'22NN<== !( #    }r!   r@   
str | Nonec                   t          |          }	 | j        |         S # t          $ r |                                rKt	          j        t                    5  |                    | j                  }ddd           n# 1 swxY w Y   | j	        D ]B}|j
                            |          r&t          |                              |          c cY S CY dS w xY w)zReturn the docname for the filename if the file is a document.

        *filename* should be absolute or relative to the source directory.
        N)r   r   KeyErroris_absolute
contextlibsuppress
ValueErrorr-   r   r   nameendswithr
   removesuffix)r   r@   rC   suffixs       r   r6   zProject.path2doc^   s2   
 H~~	(.. 
	 
	 
	!! 9(44 9 9++DK88D9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 , E E9%%f-- E)$//<<VDDDDDDDE 44
	s:    7CA<0C<B 	 CB 	A
CCCrA   r,   r1   boolr   c                    	 | j         |         }n'# t          $ r t          || j        z             }Y nw xY w|rt	          | j        |z            S t	          |          S )zReturn the filename for the document name.

        If *absolute* is True, return as an absolute path.
        Else, return as a relative path to the source directory.
        )r   rG   r   r   r   r   )r   rA   r1   r@   s       r   r;   zProject.doc2pathr   s|    	A,W5HH 	A 	A 	AGd&??@@HHH	A  	4DK(2333!!!s    !44N)r   r   r   r   r   r   )r"   r   r   r   )r%   r&   )r'   r   r(   r   r   r)   )r@   r   r   rE   )rA   r,   r1   rP   r   r   )	__name__
__module____qualname____doc__r    r$   rD   r6   r;   r%   r!   r   r   r      s        EE4 4 4 4"7 7 7 7 QX+ + + + +Z   (" " " " " "r!   r   )rU   
__future__r   rI   r<   pathlibr   typingr   sphinx.localer   sphinx.utilr   sphinx.util._pathlibr   sphinx.util.matchingr	   sphinx.util.osutilr
   collections.abcr   	getLoggerrR   r8   r5   r   r%   r!   r   <module>r`      s#   7 7 " " " " " "     				                               ) ) ) ) ) ) 3 3 3 3 3 3 - - - - - - )((((((		8	$	$>>>i" i" i" i" i" i" i" i" i" i"r!   