Merge pull request #8680 from tk0miya/deprecate_DocumenterBridge.reporter

refactor: Deprecate DocumenterBrdige.reporter
This commit is contained in:
Takeshi KOMIYA 2021-01-13 01:08:45 +09:00 committed by GitHub
commit 6101077aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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: