Skip to content

Commit

Permalink
Merge pull request sphinx-doc#9259 from tk0miya/deprecate_app
Browse files Browse the repository at this point in the history
deprecate sphinx.ext.autosummary._app
  • Loading branch information
tk0miya committed May 30, 2021
2 parents 5c27519 + 46c2e45 commit e878299
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Deprecated
* The ``app`` argument of ``sphinx.environment.BuildEnvironment`` becomes
required
* ``sphinx.application.Sphinx.html_theme``
* ``sphinx.ext.autosummary._app``
* ``sphinx.util.docstrings.extract_metadata()``

Features added
Expand Down
5 changes: 5 additions & 0 deletions doc/extdev/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ The following is a list of deprecated interfaces.
- 6.0
- ``sphinx.registry.SphinxComponentRegistry.html_themes``

* - ``sphinx.ext.autosummary._app``
- 4.1
- 6.0
- N/A

* - ``sphinx.util.docstrings.extract_metadata()``
- 4.1
- 6.0
Expand Down
13 changes: 9 additions & 4 deletions sphinx/ext/autosummary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.config import Config
from sphinx.deprecation import RemovedInSphinx50Warning
from sphinx.deprecation import (RemovedInSphinx50Warning, RemovedInSphinx60Warning,
deprecated_alias)
from sphinx.environment import BuildEnvironment
from sphinx.environment.adapters.toctree import TocTree
from sphinx.ext.autodoc import INSTANCEATTR, Documenter
Expand Down Expand Up @@ -165,9 +166,13 @@ def autosummary_table_visit_html(self: HTMLTranslator, node: autosummary_table)


# -- autodoc integration -------------------------------------------------------

# current application object (used in `get_documenter()`).
_app: Sphinx = None
deprecated_alias('sphinx.ext.autosummary',
{
'_app': None,
},
RemovedInSphinx60Warning,
{
})


class FakeApplication:
Expand Down
7 changes: 5 additions & 2 deletions sphinx/util/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ def register_application_for_autosummary(app: "Sphinx") -> None:
"""
if 'sphinx.ext.autosummary' in sys.modules:
from sphinx.ext import autosummary
autosummary._app = app
if hasattr(autosummary, '_objects'):
autosummary._objects['_app'] = app # type: ignore
else:
autosummary._app = app # type: ignore


def setup(app: "Sphinx") -> Dict[str, Any]:
app.connect('builder-inited', register_application_for_autosummary)
app.connect('builder-inited', register_application_for_autosummary, priority=100)

return {
'version': 'builtin',
Expand Down

0 comments on commit e878299

Please sign in to comment.