U
    \ªSh`  ã                   @  s|   d 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 )z6The title collector components for sphinx.environment.é    )Úannotations)ÚAny)Únodes)ÚSphinx)ÚBuildEnvironment)ÚEnvironmentCollector)ÚSphinxContentsFilterc                   @  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 )ÚTitleCollectorz'title collector for sphinx.environment.r   r   ÚstrÚNone)ÚappÚenvÚdocnameÚreturnc                 C  s    |j  |d ¡ |j |d ¡ d S ©N)ÚtitlesÚpopÚ
longtitles)Úselfr   r   r   © r   úV/root/rtd-docs/venv/lib/python3.8/site-packages/sphinx/environment/collectors/title.pyÚ	clear_doc   s    zTitleCollector.clear_doczset[str])r   r   ÚdocnamesÚotherr   c                 C  s.   |D ]$}|j | |j |< |j| |j|< qd S r   )r   r   )r   r   r   r   r   r   r   r   r   Úmerge_other   s    zTitleCollector.merge_otherznodes.document)r   Údoctreer   c                 C  s    t  ¡ }|}d|kr.t  ¡ }|t  |d ¡7 }| t j¡D ]*}t|ƒ}|d  |¡ || ¡ 7 } q|q:|t  | dd¡¡7 }||j	j
|j	j< ||j	j|j	j< dS )zAdd a title node to the document (just copy the first section title),
        and store that title in the environment.
        Útitler   z
<no title>N)r   r   ÚTextÚfindallÚsectionr   Z	walkaboutZget_entry_textÚgetr   r   r   r   )r   r   r   Z	titlenodeZlongtitlenodeÚnodeÚvisitorr   r   r   Úprocess_doc   s    zTitleCollector.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   Úsetup4   s
    
ýr*   N)r'   Ú
__future__r   Útypingr   Zdocutilsr   Zsphinx.applicationr   Zsphinx.environmentr   Zsphinx.environment.collectorsr   Zsphinx.transformsr   r	   r*   r   r   r   r   Ú<module>   s   %