Skip to content

Commit 674a782

Browse files
committed
Compatibility with Sphinx 3.0.0
"The structure of sphinx.events.EventManager.listeners has changed", from https://www.sphinx-doc.org/en/master/changes.html#release-3-0-0-released-apr-06-2020
1 parent 1eea296 commit 674a782

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

hoverxref/extension.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import inspect
33
from docutils import nodes
4+
import sphinx
45
from sphinx.roles import XRefRole
56
from sphinx.util.fileutil import copy_asset
67

@@ -76,7 +77,13 @@ def setup_sphinx_tabs(app, config):
7677
Sphinx Tabs removes the CSS/JS from pages that does not use the directive.
7778
Although, we need them to use inside the tooltip.
7879
"""
79-
listeners = list(app.events.listeners.get('html-page-context').items())
80+
if sphinx.version_info < (3, 0, 0):
81+
listeners = list(app.events.listeners.get('html-page-context').items())
82+
else:
83+
listeners = [
84+
(listener.id, listener.handler)
85+
for listener in app.events.listeners.get('html-page-context')
86+
]
8087
for listener_id, function in listeners:
8188
module_name = inspect.getmodule(function).__name__
8289
if module_name == 'sphinx_tabs.tabs':

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
envlist =
33
docs
4-
py{36,37,38}-sphinx{185,201,210,220,231}
4+
py{36,37,38}-sphinx{185,201,210,220,231,300}
55

66
[testenv]
77
deps =
@@ -13,6 +13,7 @@ deps =
1313
sphinx210: sphinx==2.1.0
1414
sphinx220: sphinx==2.2.0
1515
sphinx231: sphinx==2.3.1
16+
sphinx300: sphinx==3.0.0
1617
commands = pytest {posargs}
1718

1819
[testenv:py37-sphinx210]

0 commit comments

Comments
 (0)