Skip to content

Commit 228bb3b

Browse files
authored
Merge pull request #14 from freddrake/fd-no-force-decode
update to work with newer sphinx
2 parents 4753e6c + f1ce0d2 commit 228bb3b

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ repoze.sphinx.autointerface Changelog
44
0.8.1 (unreleased)
55
------------------
66

7+
- Update to work with newer Sphinx versions:
8+
* Sphinx.domains -> Sphinx.registry.domains
9+
* Sphinx.override_domain(D) -> Sphinx.add_domain(D, override=True)
10+
11+
- Avoid sphinx.util.force_decode on Python 3.x.
12+
713
- Drop support for Sphinx < 1.0.
814

915
0.8 (2016-03-28)

repoze/sphinx/autointerface.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11

2+
import sys
3+
24
from sphinx.util.docstrings import prepare_docstring
3-
from sphinx.util import force_decode
45
from sphinx.domains.python import PyClasslike
56
from sphinx.ext import autodoc
67
from zope.interface import Interface
78
from zope.interface.interface import InterfaceClass
89

10+
11+
if sys.version_info < (3,):
12+
from sphinx.util import force_decode
13+
else:
14+
def force_decode(s, encoding):
15+
return s
16+
17+
918
class InterfaceDesc(PyClasslike):
1019
def get_index_text(self, modname, name_cls):
1120
return '%s (interface in %s)' % (name_cls[0], modname)
@@ -98,16 +107,25 @@ def setup(app):
98107

99108
from sphinx.domains import ObjType
100109

110+
try:
111+
domains = app.domains
112+
except AttributeError:
113+
domains = app.registry.domains
114+
101115
# Allow the :class: directive to xref interface objects through the search
102116
# mechanism, i.e., prefixed with a '.', like :class:`.ITheInterface`
103117
# (without this, an exact match is required)
104-
class InterfacePythonDomain(app.domains['py']):
118+
class InterfacePythonDomain(domains['py']):
105119
pass
106-
InterfacePythonDomain.object_types = app.domains['py'].object_types.copy()
120+
InterfacePythonDomain.object_types = domains['py'].object_types.copy()
107121
InterfacePythonDomain.object_types['interface'] = ObjType( 'interface', 'interface', 'obj', 'class')
108122
old_class = InterfacePythonDomain.object_types['class']
109123
new_class = ObjType( old_class.lname, *(old_class.roles + ('interface',)), **old_class.attrs )
110124
InterfacePythonDomain.object_types['class'] = new_class
111-
app.override_domain( InterfacePythonDomain )
125+
126+
if hasattr(app, 'override_domain'):
127+
app.override_domain( InterfacePythonDomain )
128+
else:
129+
app.add_domain( InterfacePythonDomain, override=True )
112130

113131
app.add_autodocumenter(InterfaceDocumenter)

0 commit comments

Comments
 (0)