Deprecate SphinxComponentRegistry.get_source_input()

The source_input system was deprecated at v2.0.  So no client uses it
longer now.  Therefore this deprecate the getter interface and its
usage.
This commit is contained in:
Takeshi KOMIYA 2021-03-02 21:17:12 +09:00
parent 4f7f3304b1
commit 61c9c7fc58
4 changed files with 24 additions and 22 deletions

View File

@ -48,6 +48,8 @@ Deprecated
* ``sphinx.directives.patches.CSVTable`` * ``sphinx.directives.patches.CSVTable``
* ``sphinx.directives.patches.ListTable`` * ``sphinx.directives.patches.ListTable``
* ``sphinx.directives.patches.RSTTable`` * ``sphinx.directives.patches.RSTTable``
* ``sphinx.registry.SphinxComponentRegistry.get_source_input()``
* ``sphinx.registry.SphinxComponentRegistry.source_inputs``
* ``sphinx.transforms.FigureAligner`` * ``sphinx.transforms.FigureAligner``
* ``sphinx.util.pycompat.convert_with_2to3()`` * ``sphinx.util.pycompat.convert_with_2to3()``
* ``sphinx.util.pycompat.execfile_()`` * ``sphinx.util.pycompat.execfile_()``

View File

@ -47,6 +47,16 @@ The following is a list of deprecated interfaces.
- 6.0 - 6.0
- ``docutils.parsers.rst.diretives.tables.RSTTable`` - ``docutils.parsers.rst.diretives.tables.RSTTable``
* - ``sphinx.registry.SphinxComponentRegistry.get_source_input()``
- 4.0
- 6.0
- N/A
* - ``sphinx.registry.SphinxComponentRegistry.source_inputs``
- 4.0
- 6.0
- N/A
* - ``sphinx.transforms.FigureAligner`` * - ``sphinx.transforms.FigureAligner``
- 4.0 - 4.0
- 6.0 - 6.0

View File

@ -178,27 +178,12 @@ def read_doc(app: "Sphinx", env: BuildEnvironment, filename: str) -> nodes.docum
# CommonMarkParser. # CommonMarkParser.
parser.settings_spec = RSTParser.settings_spec parser.settings_spec = RSTParser.settings_spec
input_class = app.registry.get_source_input(filetype) pub = Publisher(reader=reader,
if input_class: parser=parser,
# Sphinx-1.8 style writer=SphinxDummyWriter(),
source = input_class(app, env, source=None, source_path=filename, # type: ignore source_class=SphinxFileInput,
encoding=env.config.source_encoding) destination=NullOutput())
pub = Publisher(reader=reader, pub.process_programmatic_settings(None, env.settings, None)
parser=parser, pub.set_source(source_path=filename)
writer=SphinxDummyWriter(),
source_class=SphinxDummySourceClass, # type: ignore
destination=NullOutput())
pub.process_programmatic_settings(None, env.settings, None)
pub.set_source(source, filename)
else:
# Sphinx-2.0 style
pub = Publisher(reader=reader,
parser=parser,
writer=SphinxDummyWriter(),
source_class=SphinxFileInput,
destination=NullOutput())
pub.process_programmatic_settings(None, env.settings, None)
pub.set_source(source_path=filename)
pub.publish() pub.publish()
return pub.document return pub.document

View File

@ -9,6 +9,7 @@
""" """
import traceback import traceback
import warnings
from importlib import import_module from importlib import import_module
from types import MethodType from types import MethodType
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Tuple, Type, Union from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Tuple, Type, Union
@ -23,6 +24,7 @@ from pkg_resources import iter_entry_points
from sphinx.builders import Builder from sphinx.builders import Builder
from sphinx.config import Config from sphinx.config import Config
from sphinx.deprecation import RemovedInSphinx60Warning
from sphinx.domains import Domain, Index, ObjType from sphinx.domains import Domain, Index, ObjType
from sphinx.domains.std import GenericObject, Target from sphinx.domains.std import GenericObject, Target
from sphinx.environment import BuildEnvironment from sphinx.environment import BuildEnvironment
@ -285,6 +287,9 @@ class SphinxComponentRegistry:
return parser return parser
def get_source_input(self, filetype: str) -> "Type[Input]": def get_source_input(self, filetype: str) -> "Type[Input]":
warnings.warn('SphinxComponentRegistry.get_source_input() is deprecated.',
RemovedInSphinx60Warning)
try: try:
return self.source_inputs[filetype] return self.source_inputs[filetype]
except KeyError: except KeyError: