3

T'ícN
ã@sdZddlZddlmZmZmZmZmZmZddl	Z
ddlZ
ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZmZer¼dd
lmZGdd„de
jj ƒZ Gdd„de
jj!j e ƒZ"dee#efdœdd„Z$dS)z$A Base class for additional parsers.éN)Ú
TYPE_CHECKINGÚAnyÚDictÚListÚTypeÚUnion)Únodes)Ústates)Ú
StringList)Ú	Transform)ÚSmartQuotes)ÚConfig)ÚRemovedInSphinx50Warning)ÚBuildEnvironment)Ú
append_epilogÚprepend_prolog)ÚSphinxc@s<eZdZUdZeedddœdd„Ze	ddœdd	„ƒZ
dS)
Ú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 sphinx core runtime objects (app, config and env).
    rN)ÚappÚreturncCs||_|j|_|j|_dS)z¤set_application will be called from Sphinx to set app and other instance variables

        :param sphinx.application.Sphinx app: Sphinx application object
        N)Ú_appÚconfigÚenv)Úselfr©rú0/tmp/pip-build-gk9425m9/sphinx/sphinx/parsers.pyÚset_application&szParser.set_application)rcCstjdtdd|jS)z<The application object

        .. deprecated:: 3.0
        zparser.app is deprecated.é)Ú
stacklevel)ÚwarningsÚwarnrr)rrrrr/sz
Parser.app)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
rrrrÚpropertyrrrrrrs
	rcsZeZdZdZeeedœ‡fdd„Zee	e
fejddœdd„Z
e
dd	œd
d„Z‡ZS)Ú	RSTParserzA reST parser for Sphinx.)rcstƒjƒ}|jtƒ|S)z
        Sphinx's reST parser replaces a transform class for smart-quotes by its own

        refs: sphinx.io.SphinxStandaloneReader
        )ÚsuperÚget_transformsÚremover)rZ
transforms)Ú	__class__rrr(<s

zRSTParser.get_transformsN)ÚinputstringÚdocumentrcCs‚|j||ƒtj|j|j|jjd|_t|t	ƒrTt
jj||jj
dd}t||jƒ}n|}|j|ƒ|jj|||jd|jƒdS)z(Parse text and generate a document tree.)Ú
state_classesÚ
initial_stateÚdebugT)Ú	tab_widthZconvert_whitespace)ÚinlinerN)Zsetup_parser	ZRSTStateMachiner-r.ZreporterZ
debug_flagZstatemachineÚ
isinstanceÚstrÚdocutilsZstring2linesÚsettingsr0r
Zcurrent_sourceÚdecorateÚrunr1Zfinish_parse)rr+r,ÚlinesZ
inputlinesrrrÚparseFs

zRSTParser.parse)ÚcontentrcCs t||jjƒt||jjƒdS)z'Preprocess reST content before parsing.N)rrZ
rst_prologrZ
rst_epilog)rr:rrrr6\szRSTParser.decorate)r!r"r#r$rrrr(rr3r
rr,r9r6Ú
__classcell__rr)r*rr&9s
r&r)rrcCs|jtƒddddœS)NÚbuiltinT)ÚversionZparallel_read_safeZparallel_write_safe)Zadd_source_parserr&)rrrrÚsetupbs
r>)%r$rÚtypingrrrrrrZdocutils.parsersr4Zdocutils.parsers.rstrr	Zdocutils.statemachiner
Zdocutils.transformsrZdocutils.transforms.universalrZ
sphinx.configr
Zsphinx.deprecationrZsphinx.environmentrZsphinx.util.rstrrZsphinx.applicationrÚparsersrZrstr&r3r>rrrrÚ<module>s$ ")