3

T'íc…'ã@s„dZddlZddlmZmZmZmZmZmZm	Z	ddl
mZddlm
Z
ddlmZddlmZmZddlmZdd	lmZdd
lmZddlmZmZddlmZdd
lmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&m'Z'ddl(m)Z)e$j*e+ƒZ,ej-dƒZ.Gdd„dee/ƒZ0e/ee/e/fdœdd„Z1Gdd„de0ƒZ2Gdd„de0ƒZ3Gdd„de0ƒZ4Gdd„deƒZ5eee/efd œd!d"„Z6dS)#zThe reStructuredText domain.éN)ÚAnyÚDictÚIteratorÚListÚOptionalÚTupleÚcast)ÚElement)Ú
directives)Úaddnodes)Údesc_signatureÚpending_xref)ÚSphinx)ÚBuilder)ÚObjectDescription)ÚDomainÚObjType)ÚBuildEnvironment)Ú_Ú__)ÚXRefRole)Úlogging)Úmake_idÚmake_refnode)Ú
OptionSpecz\.\. (.+?)::(.*)$c@sFeZdZdZeeeddœdd„Zeeedœdd„Zeed	œd
d„ZdS)Ú
ReSTMarkupz-
    Description of generic reST markup.
    N)ÚnameÚsigÚsignodeÚreturncCsºt|j|jj|j|ƒ}|dj|ƒ|j|ƒ}||jjjkrV||dkrV|dj|ƒ|jjj|ƒt	t
|jjdƒƒ}|j|j|||d|j
|j|ƒ}|r¶|jdjd||ddfƒdS)NÚidsÚrst)ÚlocationÚentriesÚsingleÚ)rÚenvÚstateÚdocumentÚobjtypeÚappendÚmake_old_idr Únote_explicit_targetrÚ
ReSTDomainÚ
get_domainÚnote_objectÚget_index_textÚ	indexnode)ÚselfrrrÚnode_idÚold_node_idÚdomainZ	indextext©r6ú4/tmp/pip-build-gk9425m9/sphinx/sphinx/domains/rst.pyÚadd_target_and_index s
zReSTMarkup.add_target_and_index)Ú
objectnamerrcCsdS)Nr%r6)r2r9rr6r6r7r03szReSTMarkup.get_index_text)rrcCs|jd|S)z­Generate old styled node_id for reST markups.

        .. note:: Old Styled node_id was used until Sphinx-3.0.
                  This will be removed in Sphinx-5.0.
        ú-)r))r2rr6r6r7r+6szReSTMarkup.make_old_id)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrrr8r0r+r6r6r6r7rsr)ÚdrcCsh|jƒ}|jdƒs|dfStj|ƒ}|s0|dfS|jƒ\}}|jƒrX|jƒd|jƒfS|jƒdfSdS)zŒParse a directive signature.

    Returns (directive, arguments) string tuple.  If no arguments are given,
    returns (directive, '').
    Ú.r%ú N)ÚstripÚ
startswithÚ
dir_sig_reÚmatchÚgroups)r@ÚdirÚmZ
parsed_dirZparsed_argsr6r6r7Úparse_directive?s

rJc@sPeZdZdZeeedœdd„Zeeedœdd„Zdd	œd
d„Zdd	œdd
„Z	dS)Ú
ReSTDirectivez*
    Description of a reST directive.
    )rrrcCsDt|ƒ\}}d|}|tj||ƒ7}t|ƒdkr@|tj||ƒ7}|S)Nz.. %s::r)rJrÚ	desc_nameÚlenZdesc_addname)r2rrrÚargsrLr6r6r7Úhandle_signatureWszReSTDirective.handle_signature)r9rrcCstdƒ|S)Nz%s (directive))r)r2r9rr6r6r7r0_szReSTDirective.get_index_textN)rcCs*|jr&|jjjdgƒ}|j|jdƒdS)Nzrst:directivesr)Únamesr&Úref_contextÚ
setdefaultr*)r2r
r6r6r7Úbefore_contentbszReSTDirective.before_contentcCs |jjjdgƒ}|r|jƒdS)Nzrst:directives)r&rQrRÚpop)r2r
r6r6r7Ú
after_contentgszReSTDirective.after_content)
r;r<r=r>r?rrOr0rSrUr6r6r6r7rKSs
rKc@sxeZdZUdZejjƒZeejde	j
iƒeeedœdd„Z
eeeddœdd	„Zeed
œdd„ƒZeed
œdd„ZdS)ÚReSTDirectiveOptionz6
    Description of an option for reST directive.
    Útype)rrrc
Csœytjd|jƒdƒ\}}Wntk
r8|d}}YnX|tjd|d|ƒ7}|rn|tjd|d|ƒ7}|jjdƒr˜d|jd}|tj||ƒ7}|S)Nz\s*:\s+éz:%s:rBrWz (%s))	ÚreÚsplitrCÚ
ValueErrorrrLZdesc_annotationÚoptionsÚget)r2rrrÚargumentÚtextr6r6r7rOvsz$ReSTDirectiveOption.handle_signatureN)rrrrc
Cs>tt|jjdƒƒ}|j}|r<dj|j|gƒ}dj||gƒ}n
|j}|}t|j|jj	||ƒ}|dj
|ƒ|j|ƒ}	|	|jj	jkrš|	|dkrš|dj
|	ƒ|jj	j
|ƒ|j|j|||d|r|djƒ}
tdƒ|tdƒ|g}|jd	j
d
dj|ƒ|d|
fƒn2|djƒ}
tdƒ|}|jd	j
d
||d|
fƒdS)Nr!r:ú:r )r"rz%s (directive)z:%s: (directive option)r#Úpairz; r%r$)rr-r&r.Úcurrent_directiveÚjoinr)rr'r(r*r+r r,r/Úupperrr1)
r2rrrr5Zdirective_nameÚprefixZobjnamer3r4Úkeyrar_r6r6r7r8„s,

"z(ReSTDirectiveOption.add_target_and_index)rcCs"|jjjdƒ}|r|dSdSdS)Nzrst:directivesrXr%éÿÿÿÿ)r&rQr])r2r
r6r6r7rb¥sz%ReSTDirectiveOption.current_directive)rrcCsdj|j|j|gƒS)z²Generate old styled node_id for directive options.

        .. note:: Old Styled node_id was used until Sphinx-3.0.
                  This will be removed in Sphinx-5.0.
        r:)rcr)rb)r2rr6r6r7r+­szReSTDirectiveOption.make_old_id)r;r<r=r>rZoption_specÚcopyrÚupdater
Z	unchangedr?rrOr8Úpropertyrbr+r6r6r6r7rVms
!rVc@s4eZdZdZeeedœdd„Zeeedœdd„ZdS)	ÚReSTRolez%
    Description of a reST role.
    )rrrcCs|tjd|d|ƒ7}|S)Nz:%s:)rrL)r2rrr6r6r7rOºszReSTRole.handle_signature)r9rrcCstdƒ|S)Nz	%s (role))r)r2r9rr6r6r7r0¾szReSTRole.get_index_textN)r;r<r=r>r?rrOr0r6r6r6r7rk¶srkc
@sReZdZUdZdZdZeedƒdƒeedƒdƒeedƒdƒdœZe	e
edœZe
ƒe
ƒd	œZd
iiZeeeeeefeffeeeeefeeeffdœdd
„ƒZd eeeeddœdd„Zeddœdd„Zeeeddœdd„Zeeeeeeeeedœdd„Zeeeeeeeeeefdœdd„Z e!eeeeeee"fdœdd„Z#dS)!r-zReStructuredText domain.r!ZreStructuredTextÚ	directiverHzdirective-optionÚrole)rlzdirective:optionrm)rHrmÚobjects)rcCs|jjdiƒS)Nrn)ÚdatarR)r2r6r6r7rnÙszReSTDomain.objectsN)r)rr3r"rcCsV||f|jkr<|j||f\}}tjtdƒ|||f|d|jj|f|j||f<dS)Nz4duplicate description of %s %s, other instance in %s)r")rnÚloggerÚwarningrr&Údocname)r2r)rr3r"rrr6r6r7r/Ýs

zReSTDomain.note_object)rrrcCs<x6t|jjƒƒD]$\\}}\}}||kr|j||f=qWdS)N)ÚlistrnÚitems)r2rrÚtyprÚdocZ_node_idr6r6r7Ú	clear_docås zReSTDomain.clear_doc)ÚdocnamesÚ	otherdatarcCs@x:|djƒD]*\\}}\}}||kr||f|j||f<qWdS)Nrn)rtrn)r2rxryrurrvr3r6r6r7Úmerge_domaindataêszReSTDomain.merge_domaindata)r&ÚfromdocnameÚbuilderruÚtargetÚnodeÚcontnoderc	CsP|j|ƒ}x@|D]8}	|jj|	|fdƒ\}
}|
rt|||
|||d|	ƒSqWdS)NrB)NN)Zobjtypes_for_rolernr]r)r2r&r{r|rur}r~rZobjtypesr)Ú	todocnamer3r6r6r7Úresolve_xrefðs


zReSTDomain.resolve_xref)r&r{r|r}r~rrcCs`g}xV|jD]L}|jj||fdƒ\}	}
|	r|jd|j|ƒt|||	|
||d|ƒfƒqW|S)Nzrst:rB)NN)Úobject_typesrnr]r*Zrole_for_objtyper)r2r&r{r|r}r~rÚresultsr)r€r3r6r6r7Úresolve_any_xrefûs
zReSTDomain.resolve_any_xrefccs:x4|jdjƒD]"\\}}\}}|||||dfVqWdS)NrnrX)rort)r2rurrrr3r6r6r7Úget_objectss zReSTDomain.get_objects)N)$r;r<r=r>rÚlabelrrr‚rKrVrkr
rZrolesZinitial_datarr?rrjrnrr/rwrrzrrr
r	rrr„rÚintr…r6r6r6r7r-Âs0

$(	
r-)ÚapprcCs|jtƒdddddœS)NÚbuiltinéT)ÚversionZenv_versionZparallel_read_safeZparallel_write_safe)Z
add_domainr-)rˆr6r6r7Úsetups

rŒ)7r>rYÚtypingrrrrrrrZdocutils.nodesr	Zdocutils.parsers.rstr
ZsphinxrZsphinx.addnodesrr
Zsphinx.applicationrZsphinx.buildersrZsphinx.directivesrZsphinx.domainsrrZsphinx.environmentrZ
sphinx.localerrZsphinx.rolesrZsphinx.utilrZsphinx.util.nodesrrZsphinx.util.typingrÚ	getLoggerr;rpÚcompilerEr?rrJrKrVrkr-rŒr6r6r6r7Ú<module>s2$

$IJ