o $a)@sddZddlZddlmZmZmZmZmZmZm Z m Z ddl m Z ddl mZddlmZmZddlmZddlmZdd lmZmZdd lm Z dd lmZmZmZdd lmZdd l m!Z!erfddl"m#Z#e$dZ%e$dZ&e dZ'de(de)fddZ*Gdddeee'Z+GdddeZ,GdddeZ-edde+ieddidd dee(effd!d"Z.dS)#z sphinx.directives ~~~~~~~~~~~~~~~~~ Handlers for additional ReST directives. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N) TYPE_CHECKINGAnyDictGenericListTupleTypeVarcast)nodes)Node) directivesroles)addnodes)desc_signature)RemovedInSphinx50Warningdeprecated_alias)docutils)DocFieldTransformerField TypedField)SphinxDirective) OptionSpec)Sphinxz\\\nz\\(.)TargumentreturncCs(|durdSt|}|dkrtd|S)zS Check for an integer argument or None value; raise ``ValueError`` if not. Nrz(negative value; must be positive or zero)int ValueError)rvaluer`sz4ObjectDescription.get_signatures..cSsg|]}|qSr)r7r8rrr r;bs) nl_escape_rer6 argumentssplitconfigstrip_signature_backslash)r.linesrrr get_signaturesXsz ObjectDescription.get_signaturessigsignodecCst)a Parse the signature *sig* into individual nodes and append them to *signode*. If ValueError is raised, parsing is aborted and the whole *sig* is put into a single desc_name node. The return value should be a value that identifies the object. It is passed to :meth:`add_target_and_index()` unchanged, and otherwise only used to skip duplicates. )r)r.rCrDrrr handle_signatureds z"ObjectDescription.handle_signaturer0cCdS)z Add cross-reference IDs and entries to self.indexnode, if applicable. *name* is whatever :meth:`handle_signature()` returned. Nr)r.r0rCrDrrr add_target_and_indexpsz&ObjectDescription.add_target_and_indexcCrF)z Called before parsing content. Used to set information about the current directive context on the build environment. Nrr.rrr before_contentxz ObjectDescription.before_content contentnodecCrF)z Called after creating the content through nested parsing, but before the ``object-description-transform`` event is emitted, and before the info-fields are transformed. Can be used to manipulate the content. Nr)r.rKrrr transform_contentsz#ObjectDescription.transform_contentcCrF)z Called after parsing content. Used to reset information about the current directive context on the build environment. NrrHrrr after_contentrJzObjectDescription.after_contentc Csd|jvr|jdd\|_|_nd|j|_|_tjgd|_t}|jj |_ |j|d<|j|d<|d<d|j v|d<}|jrK|d  |j|d  |dg|_ | }t|D]F\}}t|d}||| |z|||}Wnty||t||7}Yq_w||j vr|j ||s||||q_t}| ||j r|j d |jjd <||j|j|j||||jjd |j|j|t |!|d |jjd <|"|j|gS)a Main directive entry function, called by docutils upon encountering the directive. This directive is meant to be quite easily subclassable, so it delegates to several additional methods. What it does: * find out if called as a domain-specific directive, set self.domain * create a `desc` node to fit all description inside * parse standard options, currently `noindex` * create an index node if needed as self.indexnode * parse all given signatures (as returned by self.get_signatures()) using self.handle_signature(), which should either return a name or raise ValueError * add index entries using self.add_target_and_index() * parse the content and handle doc fields in it :r#r3)entriesr'r(desctyper$classesrobjectobject-description-transformN)#r0r>r'r(rindexr)descstatedocumentoptionsappendr+rB enumeraterset_source_inforErclear desc_namerG desc_contentenv temp_datarI nested_parsecontentcontent_offsetrLappemitr transform_allrM) r.noder$ signaturesirCrDr0rKrrr runsX               zObjectDescription.run)rN)&__name__ __module__ __qualname____doc__ has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer flagr%r__annotations__r&rrr'strr(r)rrTr*rrboolr2rBrrrErGrIr^rLrMr rjrrrr r"2s*       r"c@s*eZdZdZdZdZdeefddZdS) DefaultRolezK Set the default interpreted text role. Overridden from docutils. r#FrcCs|js tdgS|jd}t||jj|j|jj \}}|r-t d|||j j d<nt |j|j}|jj }|jd|||jd}||g7}ttt j|S)Nr3r default_rolez#Unknown interpreted text role "%s".)r:)r=runregister_roler role state_machinelanguagelinenorVreporter register_roler_r`r literal_block block_texterrorr rr )r. role_namerzmessagesrr~rrrr rjs"       zDefaultRole.runN) rkrlrmrnrqrrrr rjrrrr rws rwc@s@eZdZUdZdZdZdZdZiZe e d<de e fddZ d S) DefaultDomainzH Directive to (re-)set the default domain for this source file. Fr#rr%rcCs(|jd}|jj||jjd<gS)Nrdefault_domain)r=lowerr_domainsgetr`)r. domain_namerrr rjszDefaultDomain.runN)rkrlrmrnrorprqrrr%rrtrr rjrrrr rs  rzsphinx.directives DescDirectivez#sphinx.directives.ObjectDescriptionrdrcCsT|dddtdttdttdttdt|dd d d d S) Nr@Fr_z default-rolezdefault-domaindescriberRrSbuiltinT)versionparallel_read_safeparallel_write_safe)add_config_valuer register_directiverwrr" add_event)rdrrr setups     r)/rnretypingrrrrrrrr rr docutils.nodesr docutils.parsers.rstr r sphinxrsphinx.addnodesrsphinx.deprecationrr sphinx.utilsphinx.util.docfieldsrrrsphinx.util.docutilsrsphinx.util.typingrsphinx.applicationrcompiler<r5rrurr!r"rwrrrrrr s> (           )