
    Fe                        d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ erddlmZ ddlmZ  G d	 d
e	      ZddZy)z6The title collector components for sphinx.environment.    )annotations)TYPE_CHECKINGAny)nodes)EnvironmentCollector)SphinxContentsFilter)Sphinx)BuildEnvironmentc                  4    e Zd ZdZddZ	 	 	 	 	 	 ddZddZy)	TitleCollectorz'title collector for sphinx.environment.c                t    |j                   j                  |d        |j                  j                  |d        y N)titlespop
longtitles)selfappenvdocnames       E/usr/lib/python3/dist-packages/sphinx/environment/collectors/title.py	clear_doczTitleCollector.clear_doc   s(    

w%7D)    c                    |D ]:  }|j                   |   |j                   |<   |j                  |   |j                  |<   < y r   )r   r   )r   r   r   docnamesotherr   s         r   merge_otherzTitleCollector.merge_other   sC     	@G"',,w"7CJJw&+&6&6w&?CNN7#	@r   c                H   t        j                         }|}d|v r/t        j                         }|t        j                  |d         z  }|j                  t         j                        D ]5  }t        |      }|d   j                  |       ||j                         z  } n) |t        j                  |j                  dd            z  }||j                  j                  |j                  j                  <   ||j                  j                  |j                  j                  <   y)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   doctree	titlenodelongtitlenodenodevisitors          r   process_doczTitleCollector.process_doc   s     KKM	! g!KKMMUZZ(899MOOEMM2 	HD*73GGg&//11I		H GKK$FGGI*3sww'.;377??+r   N)r   r	   r   r
   r   strreturnNone)
r   r	   r   r
   r   zset[str]r   r
   r,   r-   )r   r	   r%   znodes.documentr,   r-   )__name__
__module____qualname____doc__r   r   r*    r   r   r   r      s0    1*@&@/?@DH@<r   r   c                8    | j                  t               ddddS )NbuiltinT)versionparallel_read_safeparallel_write_safe)add_env_collectorr   )r   s    r   setupr9   6   s%    .) "# r   N)r   r	   r,   zdict[str, Any])r1   
__future__r   typingr   r   docutilsr   sphinx.environment.collectorsr   sphinx.transformsr   sphinx.applicationr	   sphinx.environmentr
   r   r9   r2   r   r   <module>rA      s3    < " %  > 2)3"<) "<Jr   