B
    d                 @   s   d Z ddlmZ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eedddZeeddddZeeeef dddZdS )z7Allow reference sections by :ref: role using its title.    )AnyDictcast)nodes)NodeN)Sphinx)StandardDomain)__)logging)clean_astext)nodereturnc             C   s,   d}| }x|j | jkr&|j }|d7 }q
W |S )Nr      )parentdocument)r   iZcur_node r   h/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/sphinx/ext/autosectionlabel.pyget_node_depth   s    r   )appr   r   c       
   	   C   s  t t| jd}x|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 W 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+   )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   setup7   s    r/   )__doc__typingr   r   r   Zdocutilsr   Zdocutils.nodesr   r.   Zsphinx.applicationr   Zsphinx.domains.stdr   Zsphinx.localer	   Zsphinx.utilr
   Zsphinx.util.nodesr   	getLogger__name__r#   intr   r+   strr/   r   r   r   r   <module>   s   
	