U
    \ªSh_  ã                   @  sœ   d Z ddlm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 ddlmZ G dd„ deƒZdddœdd„ZdS )z=The dependencies collector components for sphinx.environment.é    )ÚannotationsN)Úpath)ÚAny)Únodes)Úrelative_path)ÚSphinx)ÚBuildEnvironment)ÚEnvironmentCollector)Úfs_encodingc                   @  sL   e Zd ZdZdddddœdd„Zddd	ddd
œdd„Zddddœdd„ZdS )ÚDependenciesCollectorz.dependencies collector for sphinx.environment.r   r   ÚstrÚNone)ÚappÚenvÚdocnameÚreturnc                 C  s   |j  |d ¡ d S ©N)ÚdependenciesÚpop)Úselfr   r   r   © r   ú]/root/rtd-docs/venv/lib/python3.8/site-packages/sphinx/environment/collectors/dependencies.pyÚ	clear_doc   s    zDependenciesCollector.clear_doczset[str])r   r   ÚdocnamesÚotherr   c                 C  s(   |D ]}||j kr|j | |j |< qd S r   )r   )r   r   r   r   r   r   r   r   r   Úmerge_other   s    
z!DependenciesCollector.merge_otherznodes.document)r   Údoctreer   c              	   C  s~   t  ¡ }t t |j¡d¡}|jj}|s,dS |jD ]F}t	|t
ƒrJ| t¡}t|t t ||¡¡ƒ}|jj|jj  |¡ q2dS )z+Process docutils-generated dependency info.ÚdummyN)ÚosÚgetcwdr   ÚjoinÚnormpathÚsrcdirÚsettingsZrecord_dependenciesÚlistÚ
isinstanceÚbytesÚdecoder
   r   r   r   r   Úadd)r   r   r   ÚcwdZfrompathÚdepsÚdepÚrelpathr   r   r   Úprocess_doc   s    


ÿz!DependenciesCollector.process_docN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r-   r   r   r   r   r      s   r   r   zdict[str, Any])r   r   c                 C  s   |   t¡ ddddœS )NÚbuiltinT)ÚversionZparallel_read_safeZparallel_write_safe)Zadd_env_collectorr   )r   r   r   r   Úsetup/   s
    
ýr4   )r1   Ú
__future__r   r   r   Útypingr   Zdocutilsr   Zdocutils.utilsr   Zsphinx.applicationr   Zsphinx.environmentr   Zsphinx.environment.collectorsr	   Zsphinx.util.osutilr
   r   r4   r   r   r   r   Ú<module>   s   