U
    \Sh                     @  s   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
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eZdddddZddddddZdddddZdS )z7Allow reference sections by :ref: role using its title.    )annotations)Anycast)nodes)NodeN)Sphinx)StandardDomain)__)logging)clean_astextr   int)nodereturnc                 C  s(   d}| }|j | jkr$|j }|d7 }q|S )Nr      )parentdocument)r   iZcur_node r   N/root/rtd-docs/venv/lib/python3.8/site-packages/sphinx/ext/autosectionlabel.pyget_node_depth   s    
r   r   None)appr   r   c           
   	   C  s  t t| jd}|tjD ]}| jjr<t	|| jjkr<q|d d }| jj
}t tj|d }t|d| }| jjrt|d | }n
t|}t|}	tjtd|||d|d ||jkrtjtd	|| j|j| d |d|d ||f|j|< |||	f|j|< qd S )
NZstdZidsr   Z	rawsource:z!section "%s" gets labeled as "%s"Zautosectionlabel)locationtypesubtypez(duplicate label %s, other instance in %s)r   r   envZ
get_domainfindallr   sectionconfigautosectionlabel_maxdepthr   docnametitlegetattrZastext autosectionlabel_prefix_documentZfully_normalize_namer   loggerdebugr	   labelswarningZdoc2pathZ
anonlabels)
r   r   domainr   Zlabelidr!   r"   ref_namenamesectnamer   r   r   register_sections_as_label   s>    

   

   r-   zdict[str, Any])r   r   c                 C  s6   |  ddd |  dd d | dt tjdddS )Nr$   Fr   r    zdoctree-readT)versionZparallel_read_safeZparallel_write_safe)Zadd_config_valueconnectr-   sphinxZ__display_version__)r   r   r   r   setup9   s    r1   )__doc__
__future__r   typingr   r   Zdocutilsr   Zdocutils.nodesr   r0   Zsphinx.applicationr   Zsphinx.domains.stdr   Zsphinx.localer	   Zsphinx.utilr
   Zsphinx.util.nodesr   	getLogger__name__r%   r   r-   r1   r   r   r   r   <module>   s   
	