refactor: Deprecate DocumenterBrdige.reporter

The logging system of Sphinx was migrated to sphinx.util.logging now.
So it's time to deprecate reporter interface for Documenters.
This commit is contained in:
Takeshi KOMIYA 2021-01-12 01:48:15 +09:00
parent b372a99c01
commit dffb565eea
3 changed files with 14 additions and 2 deletions

View File

@ -11,6 +11,7 @@ Deprecated
---------- ----------
* ``sphinx.ext.autodoc.AttributeDocumenter.isinstanceattribute()`` * ``sphinx.ext.autodoc.AttributeDocumenter.isinstanceattribute()``
* ``sphinx.ext.autodoc.directive.DocumenterBridge.reporter``
* ``sphinx.ext.autodoc.importer.get_module_members()`` * ``sphinx.ext.autodoc.importer.get_module_members()``
Features added Features added

View File

@ -77,6 +77,11 @@ The following is a list of deprecated interfaces.
- 5.0 - 5.0
- ``sphinx.ext.autodoc.DataDocumenter`` - ``sphinx.ext.autodoc.DataDocumenter``
* - ``sphinx.ext.autodoc.directive.DocumenterBridge.reporter``
- 3.5
- 5.0
- ``sphinx.util.logging``
* - ``sphinx.ext.autodoc.importer._getannotations()`` * - ``sphinx.ext.autodoc.importer._getannotations()``
- 3.4 - 3.4
- 4.0 - 4.0

View File

@ -16,7 +16,7 @@ from docutils.statemachine import StringList
from docutils.utils import Reporter, assemble_option_dict from docutils.utils import Reporter, assemble_option_dict
from sphinx.config import Config from sphinx.config import Config
from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.deprecation import RemovedInSphinx40Warning, RemovedInSphinx50Warning
from sphinx.environment import BuildEnvironment from sphinx.environment import BuildEnvironment
from sphinx.ext.autodoc import Documenter, Options from sphinx.ext.autodoc import Documenter, Options
from sphinx.util import logging from sphinx.util import logging
@ -55,7 +55,7 @@ class DocumenterBridge:
def __init__(self, env: BuildEnvironment, reporter: Reporter, options: Options, def __init__(self, env: BuildEnvironment, reporter: Reporter, options: Options,
lineno: int, state: Any = None) -> None: lineno: int, state: Any = None) -> None:
self.env = env self.env = env
self.reporter = reporter self._reporter = reporter
self.genopt = options self.genopt = options
self.lineno = lineno self.lineno = lineno
self.filename_set = set() # type: Set[str] self.filename_set = set() # type: Set[str]
@ -74,6 +74,12 @@ class DocumenterBridge:
def warn(self, msg: str) -> None: def warn(self, msg: str) -> None:
logger.warning(msg, location=(self.env.docname, self.lineno)) logger.warning(msg, location=(self.env.docname, self.lineno))
@property
def reporter(self) -> Reporter:
warnings.warn('DocumenterBridge.reporter is deprecated.',
RemovedInSphinx50Warning, stacklevel=2)
return self._reporter
def process_documenter_options(documenter: "Type[Documenter]", config: Config, options: Dict def process_documenter_options(documenter: "Type[Documenter]", config: Config, options: Dict
) -> Options: ) -> Options: