void-packages/srcpkgs/python3-repoze.sphinx.autointerface/patches/sphinx3.patch

61 lines
2.2 KiB
Diff
Raw Normal View History

From f1ce0d2f790ebd8e1158ac8e4a1d04715053fc38 Mon Sep 17 00:00:00 2001
From: Fred Drake <fred.drake@keepertech.com>
Date: Tue, 24 Mar 2020 15:01:46 -0400
Subject: [PATCH] update to work with newer sphinx
- avoid sphinx.util.force_decode on python 3.x
- support sphinx 3.x:
* Sphinx.domains -> Sphinx.registry.domains
* Sphinx.override_domain(D) -> Sphinx.add_domain(D, override=True)
---
repoze/sphinx/autointerface.py | 26 ++++++++++++++++++++++----
Modified by fosslinux.
diff --git repoze/sphinx/autointerface.py repoze/sphinx/autointerface.py
index 597567e..147c790 100644
--- repoze/sphinx/autointerface.py
+++ repoze/sphinx/autointerface.py
@@ -1,2 +1,10 @@
from zope.interface.interface import InterfaceClass
+
+if sys.version_info < (3,):
+ from sphinx.util import force_decode
+else:
+ def force_decode(s, encoding):
+ return s
+
+
@@ -117,17 +117,27 @@
from sphinx.domains import ObjType
+ try:
+ domains = app.domains
+ except AttributeError:
+ domains = app.registry.domains
+
# Allow the :class: directive to xref interface objects through the search
# mechanism, i.e., prefixed with a '.', like :class:`.ITheInterface`
# (without this, an exact match is required)
- class InterfacePythonDomain(app.domains['py']):
+ class InterfacePythonDomain(domains['py']):
pass
- InterfacePythonDomain.object_types = app.domains['py'].object_types.copy()
+ InterfacePythonDomain.object_types = domains['py'].object_types.copy()
InterfacePythonDomain.object_types['interface'] = ObjType( 'interface', 'interface', 'obj', 'class')
old_class = InterfacePythonDomain.object_types['class']
new_class = ObjType( old_class.lname, *(old_class.roles + ('interface',)), **old_class.attrs )
InterfacePythonDomain.object_types['class'] = new_class
- app.override_domain( InterfacePythonDomain )
+
+ if hasattr(app, 'override_domain'):
+ app.override_domain( InterfacePythonDomain )
+ else:
+ app.add_domain( InterfacePythonDomain, override=True )
+
except AttributeError:
# Sphinx < 1.0
app.add_directive('interface', InterfaceDesc)