Deprecate sphinx.parsers.Parser.app

This commit is contained in:
Takeshi KOMIYA 2019-12-27 00:13:22 +09:00
parent f2ec4bfeb7
commit 9409db0771
3 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,7 @@ Deprecated
----------
* ``sphinx.domains.std.StandardDomain.add_object()``
* ``sphinx.parsers.Parser.app``
* ``sphinx.testing.path.Path.text()``
* ``sphinx.testing.path.Path.bytes()``

View File

@ -31,6 +31,11 @@ The following is a list of deprecated interfaces.
- 5.0
- ``sphinx.domains.std.StandardDomain.note_object()``
* - ``sphinx.parsers.Parser.app``
- 3.0
- 5.0
- N/A
* - ``sphinx.testing.path.Path.text()``
- 3.0
- 5.0

View File

@ -8,6 +8,7 @@
:license: BSD, see LICENSE for details.
"""
import warnings
from typing import Any, Dict, List, Union
import docutils.parsers
@ -17,6 +18,7 @@ from docutils.parsers.rst import states
from docutils.statemachine import StringList
from docutils.transforms.universal import SmartQuotes
from sphinx.deprecation import RemovedInSphinx50Warning
from sphinx.util.rst import append_epilog, prepend_prolog
if False:
@ -47,6 +49,8 @@ class Parser(docutils.parsers.Parser):
.. deprecated:: 1.6
``warn()`` and ``info()`` is deprecated. Use :mod:`sphinx.util.logging` instead.
.. deprecated:: 3.0
parser.app is deprecated.
"""
def set_application(self, app: "Sphinx") -> None:
@ -54,10 +58,15 @@ class Parser(docutils.parsers.Parser):
:param sphinx.application.Sphinx app: Sphinx application object
"""
self.app = app
self._app = app
self.config = app.config
self.env = app.env
@property
def app(self) -> "Sphinx":
warnings.warn('parser.app is deprecated.', RemovedInSphinx50Warning)
return self._app
class RSTParser(docutils.parsers.rst.Parser, Parser):
"""A reST parser for Sphinx."""