o $a;@sdZddlZddlmZmZmZmZmZmZddl Z ddl Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZmZerRdd lmZGd d d e jjZGddde jjjeZdddeeeffddZ dS)z sphinx.parsers ~~~~~~~~~~~~~~ A Base class for additional parsers. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N) TYPE_CHECKINGAnyDictListTypeUnion)nodes)states) StringList) Transform) SmartQuotes)RemovedInSphinx50Warning) append_epilogprepend_prolog)Sphinxc@s(eZdZdZd ddZed dd ZdS) Parsera A base class of source parsers. The additional parsers should inherit this class instead of ``docutils.parsers.Parser``. Compared with ``docutils.parsers.Parser``, this class improves accessibility to Sphinx APIs. The subclasses can access the following objects and functions: self.app The application object (:class:`sphinx.application.Sphinx`) self.config The config object (:class:`sphinx.config.Config`) self.env The environment object (:class:`sphinx.environment.BuildEnvironment`) self.warn() Emit a warning. (Same as :meth:`sphinx.application.Sphinx.warn()`) self.info() Emit an info message. (Same as :meth:`sphinx.application.Sphinx.info()`) .. deprecated:: 1.6 ``warn()`` and ``info()`` is deprecated. Use :mod:`sphinx.util.logging` instead. .. deprecated:: 3.0 parser.app is deprecated. apprreturnNcCs||_|j|_|j|_dS)zset_application will be called from Sphinx to set app and other instance variables :param sphinx.application.Sphinx app: Sphinx application object N)_appconfigenv)selfrr0/usr/lib/python3/dist-packages/sphinx/parsers.pyset_application6s zParser.set_applicationcCstjdtdd|jS)Nzparser.app is deprecated.) stacklevel)warningswarnr r)rrrrr?sz Parser.app)rrrN)rr)__name__ __module__ __qualname____doc__rpropertyrrrrrrs   rcs`eZdZdZdeeeffdd Zdee e fde j ddfdd Z d e ddfd d ZZS) RSTParserzA reST parser for Sphinx.rcst}|t|S)z Sphinx's reST parser replaces a transform class for smart-quotes by its own refs: sphinx.io.SphinxStandaloneReader )superget_transformsremover )r transforms __class__rrr&Hs  zRSTParser.get_transforms inputstringdocumentNcCs|||tj|j|j|jjd|_t|t r*t jj ||j j dd}t||j}n|}|||jj|||jd|dS)z(Parse text and generate a document tree.) state_classes initial_statedebugT) tab_widthconvert_whitespace)inlinerN) setup_parser RSTStateMachiner-r.reporter debug_flag statemachine isinstancestrdocutils string2linessettingsr0r current_sourcedecoraterunr2 finish_parse)rr+r,lines inputlinesrrrparseRs    zRSTParser.parsecontentcCs t||jjt||jjdS)z'Preprocess reST content before parsing.N)rr rst_prologr rst_epilog)rrDrrrr>hszRSTParser.decorate)rr r!r"rrr r&rr9r rr,rCr> __classcell__rrr)rr$Es  r$rrrcCs|tddddS)NbuiltinT)versionparallel_read_safeparallel_write_safe)add_source_parserr$)rrrrsetupns rM)!r"rtypingrrrrrrdocutils.parsersr:docutils.parsers.rstrr docutils.statemachiner docutils.transformsr docutils.transforms.universalr sphinx.deprecationr sphinx.util.rstrrsphinx.applicationrparsersrrstr$r9rMrrrrs"        ()