B
    \                 @   sn   d Z ddlZddlZddlmZ ddlmZ ddlmZ G dd dej	j
Z
G dd	 d	ej	jj
Zd
d ZdS )z
    sphinx.parsers
    ~~~~~~~~~~~~~~

    A Base class for additional parsers.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)states)
StringList)SmartQuotesc               @   s   e Zd ZdZdd ZdS )ParseraV  
    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 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 a informational message. (Same as :meth:`sphinx.application.Sphinx.info()`)

    .. deprecated:: 1.6
       ``warn()`` and ``info()`` is deprecated.  Use :mod:`sphinx.util.logging` instead.
    c             C   s*   || _ |j| _|j| _|j| _|j| _dS )zset_application will be called from Sphinx to set app and other instance variables

        :param sphinx.application.Sphinx app: Sphinx application object
        N)appZconfigenvwarninfo)selfr    r   -lib/python3.7/site-packages/sphinx/parsers.pyset_application1   s
    zParser.set_applicationN)__name__
__module____qualname____doc__r   r   r   r   r   r      s   r   c               @   s    e Zd ZdZdd Zdd ZdS )	RSTParserzA reST parser for Sphinx.c             C   s   t jjj| }|t |S )zySphinx's reST parser replaces a transform class for smart-quotes by own's

        refs: sphinx.io.SphinxStandaloneReader)docutilsparsersrstr   get_transformsremover   )r
   Z
transformsr   r   r   r   A   s    
zRSTParser.get_transformsc             C   sf   t |trN| || tj| j| j|jjd| _	| j	j
||| jd |   ntjjj| || dS )zParse text and generate a document tree.

        This accepts StringList as an inputstring parameter.
        It enables to handle mixed contents (cf. :confval:`rst_prolog`) correctly.
        )state_classesinitial_statedebug)inlinerN)
isinstancer   Zsetup_parser   ZRSTStateMachiner   r   ZreporterZ
debug_flagZstatemachinerunr   Zfinish_parser   r   r   r   parse)r
   ZinputstringZdocumentr   r   r   r   J   s    

zRSTParser.parseN)r   r   r   r   r   r   r   r   r   r   r   >   s   	r   c             C   s   |  t ddddS )NZbuiltinT)versionZparallel_read_safeZparallel_write_safe)Zadd_source_parserr   )r   r   r   r   setup_   s    
r    )r   Zdocutils.parsersr   Zdocutils.parsers.rstr   Zdocutils.statemachiner   Zdocutils.transforms.universalr   r   r   r   r   r    r   r   r   r   <module>
   s   
$!