o
    Ni	                     @  s   d Z ddlmZ ddlmZ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 er@dd	lmZ dd
lmZ ddlmZ eeZdddZdddZdddZdS )z7Allow reference sections by :ref: role using its title.    )annotations)TYPE_CHECKINGcast)nodesN)__)logging)clean_astext)Node)Sphinx)ExtensionMetadatanoder	   returnintc                 C  s2   d}| }|j | jkr|j }|d7 }|j | jks
|S )Nr      )parentdocument)r   icur_node r   O/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/ext/autosectionlabel.pyget_node_depth   s   r   appr
   r   Nonec           
   	   C  s
  | j jj}|tjD ]w}| jjrt|| jjkrq|d d }| j j	}t
tj|d }t|d| }| jjrBt|d | }nt|}t|}	tjtd|||d|d ||jv rstjtd|| j |j| d |d|d ||f|j|< |||	f|j|< qd S )	Nidsr   	rawsource:z!section "%s" gets labeled as "%s"autosectionlabel)locationtypesubtypez(duplicate label %s, other instance in %s)envdomainsstandard_domainfindallr   sectionconfigautosectionlabel_maxdepthr   docnamer   titlegetattrastext autosectionlabel_prefix_documentfully_normalize_namer   loggerdebugr   labelswarningdoc2path
anonlabels)
r   r   domainr   labelidr'   r(   ref_namenamesectnamer   r   r   register_sections_as_label    s2   




r8   r   c                 C  s6   |  ddd |  dd d | dt tjdddS )Nr+   Fr    r&   zdoctree-readT)versionparallel_read_safeparallel_write_safe)add_config_valueconnectr8   sphinx__display_version__)r   r   r   r   setup<   s   r@   )r   r	   r   r   )r   r
   r   r	   r   r   )r   r
   r   r   )__doc__
__future__r   typingr   r   docutilsr   r>   sphinx.localer   sphinx.utilr   sphinx.util.nodesr   docutils.nodesr	   sphinx.applicationr
   sphinx.util.typingr   	getLogger__name__r-   r   r8   r@   r   r   r   r   <module>   s     


	