o
    N iù  ã                   @  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
 er4ddlmZ ddlmZ dd	lmZ G d
d„ deƒZddd„ZdS )z6The title collector components for sphinx.environment.é    )Úannotations)ÚTYPE_CHECKING)Únodes)ÚEnvironmentCollector)ÚSphinxContentsFilter)ÚSphinx)ÚBuildEnvironment)ÚExtensionMetadatac                   @  s.   e Zd ZdZdd
d„Zddd„Zddd„ZdS )ÚTitleCollectorz'title collector for sphinx.environment.Úappr   Úenvr   ÚdocnameÚstrÚreturnÚNonec                 C  s    |j  |d ¡ |j |d ¡ d S ©N)ÚtitlesÚpopÚ
longtitles)Úselfr   r   r   © r   úW/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/environment/collectors/title.pyÚ	clear_doc   s   zTitleCollector.clear_docÚdocnamesúset[str]Úotherc                 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_otherÚdoctreeúnodes.documentc                 C  sž   t  ¡ }|}d|v rt  ¡ }|t  |d ¡7 }| t j¡D ]}t|ƒ}|d  |¡ || ¡ 7 } n|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   Ú	walkaboutÚget_entry_textÚgetr   r   r   r   )r   r   r   Ú	titlenodeÚlongtitlenodeÚnodeÚvisitorr   r   r   Úprocess_doc$   s   zTitleCollector.process_docN)r   r   r   r   r   r   r   r   )
r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r*   r   r   r   r   r
      s
    

r
   r   r   r   r	   c                 C  s   |   t¡ ddddœS )NÚbuiltinT)ÚversionÚparallel_read_safeÚparallel_write_safe)Úadd_env_collectorr
   )r   r   r   r   Úsetup<   s
   
ýr4   N)r   r   r   r	   )r.   Ú
__future__r   Útypingr   Údocutilsr   Úsphinx.environment.collectorsr   Úsphinx.transformsr   Úsphinx.applicationr   Úsphinx.environmentr   Úsphinx.util.typingr	   r
   r4   r   r   r   r   Ú<module>   s    *