o $aH#@sdZddlZddlZddlmZddlmZmZmZmZm Z m Z ddl m Z ddl mZmZmZddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)m*Z*m+Z+ddl,m-Z-zddl m.Z/ddl0m1Z2Wne3yddl4m1Z2ddl4m5Z5e5j.Z/Ynwerddl6m7Z7e#8e9Z:Gdddej;Z;Gddde2e%Z1Gdddej<ZZ>Gd"d#d#e%Z?Gd$d%d%e%Z@d&d'd(eeAeffd)d*ZBdS)+z sphinx.directives.patches ~~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)path) TYPE_CHECKINGAnyDictListTuplecast)nodes)Nodemake_idsystem_message) directives)imagestables) set_classes)addnodes)RemovedInSphinx60Warning) optional_int) MathDomain)__)logging)SphinxDirective)set_source_info)SEPos_pathrelpath) OptionSpec)meta)Meta)MetaBody)Sphinxc*eZdZdZdeeffdd ZZS)FigureziThe figure directive which applies `:name:` option to the figure node instead of the image node. returncs|jdd}t}t|dkst|dtjr|St|dks$Jttj |d}|r8||jd<| ||j durOt|dkrOttj |d}|j |_ |gS)Nnamer) optionspopsuperrunlen isinstancer r rfigureadd_namelinecaption)selfr$result figure_noder0 __class__;/usr/lib/python3/dist-packages/sphinx/directives/patches.pyr*4s   z Figure.run__name__ __module__ __qualname____doc__rr r* __classcell__r6r6r4r7r"/r"cs&eZdZdeeffdd ZZS)rr#csrt}|D]/}t|tjr6t|jddtr6|jdd}|j|jj |_ |j |_ |d|_ tj|_q|S)Nr rcontent)r)r*r,r pendingdetails meta_nodeenvdoc2pathdocnamesourcelinenor/ rawcontentrrr5)r1r2noderr4r6r7r*Js   zMeta.run)r9r:r;rr r*r=r6r6r4r7rIsrcJeZdZdZdeeffdd Zdeej ee fffdd Z Z S)RSTTablezxThe table directive which sets source and line information to its caption. Only for docutils-0.13 or older version.r#ctdttS)NzRSTTable is deprecated.warningswarnrr)r*r1r4r6r7r*_ z RSTTable.runc$t\}}|rt||||fSNr) make_titlerr1titlemessager4r6r7rUd zRSTTable.make_title r9r:r;r<rr r*rr rWr rUr=r6r6r4r7rKZ(rKcr!)CSVTablezThe csv-table directive which searches a CSV file from Sphinx project's source directory when an absolute path is given via :file: option. r#csd|jvrO|jdttjfrO|jjjj}|jd}t |r.t j t d|j|jfdn!t |jt|jddd}t ||j}t|||jd<tS)Nfilez":file:" option for csv-table directive now recognizes an absolute path as a relative path from source directory. Please update your document.locationr&)r' startswithrossepstatedocumentsettingsrCrexistsloggerwarningrrErGjoinsrcdirrdirnamerDrr)r*)r1rCfilenameabspathdocdirr4r6r7r*qs        z CSVTable.runr8r6r6r4r7r\lr>r\crJ) ListTablez}The list-table directive which sets source and line information to its caption. Only for docutils-0.13 or older version.r#crL)NzListTable is deprecated.rMrPr4r6r7r*rQz ListTable.runcrRrSrTrVr4r6r7rUrYzListTable.make_titlerZr6r6r4r7ror[roc@sHeZdZUdZdZejejeje dZ e e d<dZ deefddZd S) CodezqParse and mark up content of a code block. This is compatible with docutils' :rst:dir:`code` directive. r&)classforcer$ number-lines option_specTr#cCs|t|jd|j}tj|||jdgd|jvid}||t |||j r6|j d|d<n |j j d|j j|d<d|jvrYd |d <|jdrY|jd|d d <|gS) N classesrr)rvrrhighlight_argsrlanguagehighlight_languagersTlinenosrw linenostart)assert_has_contentrr'rir?r literal_blockgetr.r argumentsrC temp_dataconfigry)r1coderIr6r6r7r*s(        zCode.runN)r9r:r;r<optional_argumentsr class_optionflag unchangedrrtr__annotations__ has_contentrr r*r6r6r6r7rps rpc@sdeZdZUdZdZdZdZejejej ej dZ e e d<deefddZd eedd fd d Zd S) MathDirectiveTrr&)labelr$rqnowraprtr#c Csd|j}|jr|jdr|jdd|}|jd|jd}tj|||jdg|jjd|d|jvd}| || ||g}| ||S) Nrurz rr$rqr)rvrEnumberrr) rir?rr'r~r math_blockrCrEr.r add_target)r1latexrrIretr6r6r7r*s     zMathDirective.runrNcCsttj|d}|ddks|jjr&|ds&|jd}d|jj|f|d<|ds,dStt|j d}|j |jj|d|d| |d|d<t d |d}tj dd|gd }|jj||d|dS) Nrrzsphinx.ext.math#equationsz%s:%dmathr^rz equation-%s)ids)rr rrmath_number_allrC new_serialnorEr get_domain note_equationget_equation_number_forr targetrcrdnote_explicit_targetinsert)r1rrIseqdomainnode_idrr6r6r7rs zMathDirective.add_target)r9r:r;rrequired_argumentsrfinal_argument_whitespacer rrrrtrrrr r*rr6r6r6r7rs rappr r#cCsHtdttdttdttdttdtddddS) Nr-rz csv-tablerrbuiltinT)versionparallel_read_safeparallel_write_safe)r register_directiver"rr\rpr)rr6r6r7setups     r)Cr<rarNrtypingrrrrrrdocutilsr docutils.nodesr r r docutils.parsers.rstr docutils.parsers.rst.directivesrrdocutils.parsers.rst.rolesrsphinxrsphinx.deprecationrsphinx.directivesrsphinx.domains.mathr sphinx.localer sphinx.utilrsphinx.util.docutilsrsphinx.util.nodesrsphinx.util.osutilrrrsphinx.util.typingrrrB$docutils.parsers.rst.directives.miscrMetaBase ImportError$docutils.parsers.rst.directives.htmlrsphinx.applicationr getLoggerr9rgr"rKr\rorprstrrr6r6r6r7sN                     .6