
    Ri                        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y)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                  R    e Zd ZdZ	 	 	 	 	 	 ddZd	dZ	 d
	 	 	 	 	 ddZddZddZy)Projectz;A project is the source code set of the Sphinx document(s).c                    t        |      | _        t        |      | _        t	        t        | j                        d      | _        t               | _        i | _	        i | _
        y )N )r   srcdirtuplesource_suffixnextiter_first_source_suffixsetdocnames_path_to_docname_docname_to_path)selfr   r   s      F/home/agent/.friday_env/lib/python3.12/site-packages/sphinx/project.py__init__zProject.__init__   sV     v& #=1$(d.@.@)A2$F! #&% 2413    c                j    |j                   | _         |j                  | _        |j                  | _        y)z!Take over a result of last build.N)r   r   r   )r   others     r   restorezProject.restore+   s)     % 6 6 % 6 6r   c           
        | j                   j                          | j                  j                          | j                  j                          t	        | j
                  |g |t              D ]N  }| j                  |      x}s|| j                   v r| j
                  j                  | d      D cg c]&  }t        |j                  | j
                              ( }}t        j                  t        d      |dj                  |      | j                  |d      d       t!        j"                  | j
                  |z  t         j$                        rF| j                   j'                  |       t)        |      }|| j                  |<   || j                  |<   .t        j                  t        d      ||       Q | j                   S c c}w )	zbFind all document files in the source directory and put them in
        :attr:`docnames`.
        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strrelative_tologgerwarningr   joindoc2pathosaccessR_OKaddr   )r   exclude_pathsinclude_pathsfilenamedocnameffilespaths           r   discoverzProject.discover1   s    	##%##%*KK,m,m,
 	H
 --11w1dmm+ "&!1!1WIR.!A AMM$++67E  NN4  		%(g=! # 	 YYt{{X5rww?MM%%g.>D29D))$/59D))'2NN<= !( # 7	B }}5s   4+Gc                   t        |      }	 | j                  |   S # t        $ r |j                         rJt	        j
                  t              5  |j                  | j                        }ddd       n# 1 sw Y   nxY w| j                  D ];  }|j                  j                  |      st        |      j                  |      c cY S  Y y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   r5   r9   suffixs       r   r'   zProject.path2doc^   s    
 H~	((.. 
	!((4 9++DKK8D9 9 9 ,, E99%%f-)$/<<VDDE
 
	s3    2CA3*	C3A<	81C*CCCc                    	 | j                   |   }|rt	        | j
                  |z        S t	        |      S # t        $ r t        || j                  z         }Y Hw xY w)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   r<   r   r   r   r   )r   r6   r"   r5   s       r   r.   zProject.doc2pathr   sd    	A,,W5H
 DKK(233!!  	AGd&?&??@H	As   6 !AAN)r   str | os.PathLike[str]r   Iterable[str]returnNone)r   r   rH   rI   ) )z**)r3   rG   r4   rG   rH   zset[str])r5   rF   rH   z
str | None)r6   r)   r"   boolrH   r   )	__name__
__module____qualname____doc__r   r    r:   r'   r.   rJ   r   r   r   r      sV    E4,4=J4	4"7 QX+*+@M+	+Z("r   r   )rO   
__future__r   r>   r/   pathlibr   typingr   sphinx.localer   sphinx.utilr   sphinx.util._pathlibr   sphinx.util.matchingr	   sphinx.util.osutilr
   collections.abcr   	getLoggerrL   r+   r&   r   rJ   r   r   <module>rZ      sO    7 "  	      ) 3 -(			8	$>i" i"r   