3

T'ícã@s´dZddlmZmZmZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZdd	lmZejeƒZeed
œdd„Ze
ed
dœdd„Ze
eeefdœdd„Zd
S)z7Allow reference sections by :ref: role using its title.é)ÚAnyÚDictÚcast)Únodes)ÚNode)ÚSphinx)ÚStandardDomain)Ú__)Úlogging)Úclean_astext)ÚnodeÚreturncCs,d}|}x|j|jkr&|j}|d7}q
W|S)Nré)ÚparentÚdocument)rÚiZcur_node©rú=/tmp/pip-build-gk9425m9/sphinx/sphinx/ext/autosectionlabel.pyÚget_node_depthsrN)Úapprr
c
	Csütt|jjdƒƒ}xä|jtjƒD]Ô}|jjr>t	|ƒ|jjkr>q |dd}|jj
}ttj|dƒ}t|d|j
ƒƒ}|jjrŽtj|d|ƒ}n
tj|ƒ}t|ƒ}	||jkrÖtjtdƒ||jj|j|dƒ|d|d||f|j|<|||	f|j|<q WdS)	NZstdÚidsrZ	rawsourceú:z(duplicate label %s, other instance in %sZautosectionlabel)ÚlocationÚtypeÚsubtype)rrÚenvZ
get_domainÚfindallrÚsectionÚconfigÚautosectionlabel_maxdepthrÚdocnameÚtitleÚgetattrZastextÚ autosectionlabel_prefix_documentZfully_normalize_namerÚlabelsÚloggerÚwarningr	Zdoc2pathZ
anonlabels)
rrÚdomainrZlabelidr r!Úref_nameÚnameÚsectnamerrrÚregister_sections_as_labels&


r+)rr
cCs4|jdddƒ|jdddƒ|jdtƒddddœS)	Nr#Frrzdoctree-readÚbuiltinT)ÚversionZparallel_read_safeZparallel_write_safe)Zadd_config_valueÚconnectr+)rrrrÚsetup3sr/)Ú__doc__ÚtypingrrrZdocutilsrZdocutils.nodesrZsphinx.applicationrZsphinx.domains.stdrZ
sphinx.localer	Zsphinx.utilr
Zsphinx.util.nodesrÚ	getLoggerÚ__name__r%Úintrr+Ústrr/rrrrÚ<module>s