Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2022-03-27 13:45:41 +0300
committerGitHub <noreply@github.com>2022-03-27 13:45:41 +0300
commitf559389d14d32b1cc70792a5bbbbdfb963e0ce6a (patch)
treeae68b5c2e500b2fcbe752d96a4cf4212dc912bd7
parent7ae8c1ee4294275f67dd3684d16963435c7b3c5b (diff)
parente530c00b828d2e9343905a32622506e954e06906 (diff)
Merge pull request #10301 from tk0miya/refactor_parserapi_doc
doc: Update docs for sphinx.parsers.Parser
-rw-r--r--doc/extdev/parserapi.rst1
-rw-r--r--sphinx/parsers.py30
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