diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-03-27 10:22:44 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-03-27 13:27:53 +0300 |
commit | e530c00b828d2e9343905a32622506e954e06906 (patch) | |
tree | 878dc362efa6278d7e4ac7e6d0b6997a1b4c57bf | |
parent | 7ffc606e0ca302a7c4c43c65b2060ba31de43a3d (diff) |
doc: Update docs for sphinx.parsers.Parser
-rw-r--r-- | doc/extdev/parserapi.rst | 1 | ||||
-rw-r--r-- | sphinx/parsers.py | 30 |
2 files changed, 14 insertions, 17 deletions
diff --git a/doc/extdev/parserapi.rst b/doc/extdev/parserapi.rst index 1bd03fd09..c5db2ac97 100644 --- a/doc/extdev/parserapi.rst +++ b/doc/extdev/parserapi.rst @@ -35,3 +35,4 @@ to configure their settings appropriately. .. module:: sphinx.parsers .. autoclass:: Parser + :members: diff --git a/sphinx/parsers.py b/sphinx/parsers.py index b044f983b..6fd74b0cd 100644 --- a/sphinx/parsers.py +++ b/sphinx/parsers.py @@ -11,7 +11,9 @@ from docutils.statemachine import StringList from docutils.transforms import Transform from docutils.transforms.universal import SmartQuotes +from sphinx.config import Config from sphinx.deprecation import RemovedInSphinx50Warning +from sphinx.environment import BuildEnvironment from sphinx.util.rst import append_epilog, prepend_prolog if TYPE_CHECKING: @@ -24,25 +26,15 @@ class Parser(docutils.parsers.Parser): 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. + The subclasses can access sphinx core runtime objects (app, config and env). """ + #: The config object + config: Config + + #: The environment object + env: BuildEnvironment + def set_application(self, app: "Sphinx") -> None: """set_application will be called from Sphinx to set app and other instance variables @@ -54,6 +46,10 @@ class Parser(docutils.parsers.Parser): @property def app(self) -> "Sphinx": + """The application object + + .. deprecated:: 3.0 + """ warnings.warn('parser.app is deprecated.', RemovedInSphinx50Warning, stacklevel=2) return self._app |