3

T'ícäã@sdZddlmZmZmZmZmZmZddlm	Z	ddl
mZmZddl
mZddlmZddlmZddlmZdd	lmZmZdd
lmZmZddlmZddlmZer¸dd
lm Z ej!e"ƒZ#Gdd„deƒZ$Gdd„deƒZ%Gdd„deƒZ&dee'efdœdd„Z(dS)zThe index domain.é)Ú
TYPE_CHECKINGÚAnyÚDictÚIterableÚListÚTuple)Únodes)ÚNodeÚsystem_message)Ú
directives)Úaddnodes)ÚDomain)ÚBuildEnvironment)ÚloggingÚsplit_index_msg)Ú
ReferenceRoleÚSphinxDirective)Úprocess_index_entry)Ú
OptionSpec)ÚSphinxc
@s~eZdZdZdZdZeeee	e
eeeeeffdœdd„ƒZeddœdd	„Ze
eedd
œdd„Zeeedd
œdd„ZdS)ÚIndexDomainzMathematics domain.Úindex)ÚreturncCs|jjdiƒS)NÚentries)ÚdataÚ
setdefault)Úself©rú6/tmp/pip-build-gk9425m9/sphinx/sphinx/domains/index.pyrszIndexDomain.entriesN)ÚdocnamercCs|jj|dƒdS)N)rÚpop)rrrrrÚ	clear_doc!szIndexDomain.clear_doc)ÚdocnamesÚ	otherdatarcCs$x|D]}|d||j|<qWdS)Nr)r)rr"r#rrrrÚmerge_domaindata$s
zIndexDomain.merge_domaindata)ÚenvrÚdocumentrcCs´|jj|jgƒ}xžt|jtjƒƒD]Š}y(x"|dD]}t|d|dƒq2WWn@tk
rŽ}z$t	j
t|ƒ|d|jj
|ƒWYdd}~Xq"Xx|dD]}|j|ƒqšWq"WdS)z7Process a document after it is read by the environment.rré)ÚlocationN)rrrÚlistÚfindallrrrÚ
ValueErrorÚloggerÚwarningÚstrÚparentÚremoveÚappend)rr%rr&rÚnodeÚentryÚexcrrrÚprocess_doc(szIndexDomain.process_doc)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚlabelÚpropertyrr.rrrr!rr$rr	r5rrrrrs*rc@sBeZdZUdZdZdZdZdZdej	iZ
e
ee
dœdd	„Zd
S)ÚIndexDirectivez0
    Directive to add entries to the index.
    Fr'rTr:)rcCs¼|jdjdƒ}d|jkr8|jd}tjdd|gd}n"d|jjdƒ}tjdd|gd}|jjj	|ƒt
jƒ}g|d	<d
|d<|j|ƒx(|D] }|d	j
t||ddƒƒqW||gS)
NrÚ
r:Ú)Únameszindex-%sr)ÚidsrFÚinlinerA)Ú	argumentsÚsplitÚoptionsrÚtargetr%Únew_serialnoÚstater&Znote_explicit_targetrrÚset_source_infoÚextendr)rrCZ
targetnameZ
targetnodeZtargetidZ	indexnoder3rrrÚrunCs



 zIndexDirective.runN)r6r7r8r9Zhas_contentZrequired_argumentsZoptional_argumentsZfinal_argument_whitespacerZ	unchangedZoption_specrrr	rKrrrrr=7s
r=c@s*eZdZeeeeefdœdd„ZdS)Ú	IndexRole)rcCsºd|jjdƒ}|jr*|j}t|j|ƒ}nN|jjdƒr`|jdd…}d|jdd…|ddfg}n|j}d|j|ddfg}tj|d}t	jdd|gd	}t	j
||ƒ}|j|ƒ|||ggfS)
Nzindex-%srú!r'ZsingleÚmainr?)r)rA)r%rGZhas_explicit_titleÚtitlerrFÚ
startswithrrrZTextrI)rZ	target_idrOrrrFÚtextrrrrKXs
z
IndexRole.runN)r6r7r8rrr	r
rKrrrrrLWsrLr)ÚapprcCs2|jtƒ|jdtƒ|jdtƒƒdddddœS)NrÚbuiltinr'T)ÚversionZenv_versionZparallel_read_safeZparallel_write_safe)Z
add_domainrZ
add_directiver=Zadd_rolerL)rRrrrÚsetupns
rUN))r9ÚtypingrrrrrrZdocutilsrZdocutils.nodesr	r
Zdocutils.parsers.rstrZsphinxrZsphinx.domainsr
Zsphinx.environmentrZsphinx.utilrrZsphinx.util.docutilsrrZsphinx.util.nodesrZsphinx.util.typingrZsphinx.applicationrÚ	getLoggerr6r,rr=rLr.rUrrrrÚ<module>s$