fix for Sphinx 1.6 compatibility (RHBZ#1473447)

This commit is contained in:
Dan Callaghan 2017-07-24 11:47:00 +10:00
parent c4a85f8496
commit d6f7dd2123
5 changed files with 250 additions and 7 deletions

View File

@ -0,0 +1,125 @@
From 9b47b140c0b36c3914eb8314511098a39311c27b Mon Sep 17 00:00:00 2001
From: Dave Shawley <daveshawley@gmail.com>
Date: Fri, 23 Jun 2017 07:12:18 -0400
Subject: [PATCH 1/4] Update 'http' domain detection to work with new Sphinx.
The autohttp.*.setup functions were detecting whether httpdomain was
installed using an attribute on the sphinx application that was removed
in recent Sphinx versions. This commit:
(1) moves the idempotency logic into httpdomain.setup
(2) makes the logic work with new and old versions of sphinx by
falling back to the legacy behavior on AttributeError
(3) changes each setup function to always call the new idempotent
httpdomain.setup
---
httpdomain/sphinxcontrib/autohttp/bottle.py | 3 +--
httpdomain/sphinxcontrib/autohttp/flask.py | 3 +--
httpdomain/sphinxcontrib/autohttp/flaskqref.py | 13 ++++++-------
httpdomain/sphinxcontrib/autohttp/tornado.py | 3 +--
httpdomain/sphinxcontrib/httpdomain.py | 8 +++++++-
5 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/httpdomain/sphinxcontrib/autohttp/bottle.py b/httpdomain/sphinxcontrib/autohttp/bottle.py
index d8c1859..306cadd 100644
--- a/httpdomain/sphinxcontrib/autohttp/bottle.py
+++ b/httpdomain/sphinxcontrib/autohttp/bottle.py
@@ -108,7 +108,6 @@ def run(self):
def setup(app):
- if 'http' not in app.domains:
- httpdomain.setup(app)
+ httpdomain.setup(app)
app.add_directive('autobottle', AutobottleDirective)
diff --git a/httpdomain/sphinxcontrib/autohttp/flask.py b/httpdomain/sphinxcontrib/autohttp/flask.py
index 4bd5232..be65f35 100644
--- a/httpdomain/sphinxcontrib/autohttp/flask.py
+++ b/httpdomain/sphinxcontrib/autohttp/flask.py
@@ -43,6 +43,5 @@ def run(self):
def setup(app):
- if 'http' not in app.domains:
- httpdomain.setup(app)
+ httpdomain.setup(app)
app.add_directive('autoflask', AutoflaskDirective)
diff --git a/httpdomain/sphinxcontrib/autohttp/flaskqref.py b/httpdomain/sphinxcontrib/autohttp/flaskqref.py
index c28bb15..3a70b4b 100644
--- a/httpdomain/sphinxcontrib/autohttp/flaskqref.py
+++ b/httpdomain/sphinxcontrib/autohttp/flaskqref.py
@@ -2,7 +2,7 @@
sphinxcontrib.autohttp.flaskqref
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- The sphinx.ext.autodoc-style HTTP API quick reference
+ The sphinx.ext.autodoc-style HTTP API quick reference
builder (from Flask)
for sphinxcontrib.httpdomain.
@@ -38,15 +38,15 @@ def run(self):
node.document = self.state.document
result = ViewList()
for line in QuickReferenceFlaskDirective.header:
- result.append(line, '<qrefflask>')
+ result.append(line, '<qrefflask>')
table={}
table_sorted_names=[]
-
+
for table_row in self.make_rst(qref=True):
name = table_row['name']
if table.get(name) is None:
table[name]=[]
- table[name].append(table_row)
+ table[name].append(table_row)
if name not in table_sorted_names:
table_sorted_names.append(name)
@@ -72,9 +72,8 @@ def run(self):
result.append('', '<qrefflask>')
nested_parse_with_titles(self.state, result, node)
return node.children
-
+
def setup(app):
- if 'http' not in app.domains:
- httpdomain.setup(app)
+ httpdomain.setup(app)
app.add_directive('qrefflask', QuickReferenceFlaskDirective)
diff --git a/httpdomain/sphinxcontrib/autohttp/tornado.py b/httpdomain/sphinxcontrib/autohttp/tornado.py
index 9a514fe..8efd343 100644
--- a/httpdomain/sphinxcontrib/autohttp/tornado.py
+++ b/httpdomain/sphinxcontrib/autohttp/tornado.py
@@ -123,6 +123,5 @@ def run(self):
def setup(app):
- if 'http' not in app.domains:
- httpdomain.setup(app)
+ httpdomain.setup(app)
app.add_directive('autotornado', AutoTornadoDirective)
diff --git a/httpdomain/sphinxcontrib/httpdomain.py b/httpdomain/sphinxcontrib/httpdomain.py
index d5c30a4..9812671 100644
--- a/httpdomain/sphinxcontrib/httpdomain.py
+++ b/httpdomain/sphinxcontrib/httpdomain.py
@@ -756,7 +756,13 @@ def content_callback(self, match):
def setup(app):
- app.add_domain(HTTPDomain)
+ try:
+ if app.registry.has_domain(HTTPDomain.name):
+ return
+ except AttributeError:
+ if HTTPDomain.name in app.domains:
+ return
+
try:
get_lexer_by_name('http')
except ClassNotFound:
--
2.9.4

View File

@ -0,0 +1,25 @@
From 482c93aa46b79d0d0d2d0386c71288ec5e666a0b Mon Sep 17 00:00:00 2001
From: Dave Shawley <daveshawley@gmail.com>
Date: Tue, 27 Jun 2017 08:01:21 -0400
Subject: [PATCH 2/4] httpdomain: Add missing call to add_domain.
---
httpdomain/sphinxcontrib/httpdomain.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/httpdomain/sphinxcontrib/httpdomain.py b/httpdomain/sphinxcontrib/httpdomain.py
index 9812671..6a25e2e 100644
--- a/httpdomain/sphinxcontrib/httpdomain.py
+++ b/httpdomain/sphinxcontrib/httpdomain.py
@@ -763,6 +763,8 @@ def setup(app):
if HTTPDomain.name in app.domains:
return
+ app.add_domain(HTTPDomain)
+
try:
get_lexer_by_name('http')
except ClassNotFound:
--
2.9.4

View File

@ -0,0 +1,82 @@
From 8d0b0ecd213e668529b531f618e10e4eaadc6340 Mon Sep 17 00:00:00 2001
From: Dave Shawley <daveshawley@gmail.com>
Date: Tue, 27 Jun 2017 08:11:57 -0400
Subject: [PATCH 3/4] httpdomain/autohttp: Use app.setup_extension.
This method has been available since sphinx 1.0 so there is no need to wrap
this in "version safety" checks and it is significantly cleaner.
---
httpdomain/sphinxcontrib/autohttp/bottle.py | 3 +--
httpdomain/sphinxcontrib/autohttp/flask.py | 2 +-
httpdomain/sphinxcontrib/autohttp/flaskqref.py | 3 +--
httpdomain/sphinxcontrib/autohttp/tornado.py | 2 +-
httpdomain/sphinxcontrib/httpdomain.py | 7 -------
5 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/httpdomain/sphinxcontrib/autohttp/bottle.py b/httpdomain/sphinxcontrib/autohttp/bottle.py
index 306cadd..adf6c77 100644
--- a/httpdomain/sphinxcontrib/autohttp/bottle.py
+++ b/httpdomain/sphinxcontrib/autohttp/bottle.py
@@ -108,6 +108,5 @@ def run(self):
def setup(app):
- httpdomain.setup(app)
+ app.setup_extension('sphinxcontrib.httpdomain')
app.add_directive('autobottle', AutobottleDirective)
-
diff --git a/httpdomain/sphinxcontrib/autohttp/flask.py b/httpdomain/sphinxcontrib/autohttp/flask.py
index be65f35..b1fac45 100644
--- a/httpdomain/sphinxcontrib/autohttp/flask.py
+++ b/httpdomain/sphinxcontrib/autohttp/flask.py
@@ -43,5 +43,5 @@ def run(self):
def setup(app):
- httpdomain.setup(app)
+ app.setup_extension('sphinxcontrib.httpdomain')
app.add_directive('autoflask', AutoflaskDirective)
diff --git a/httpdomain/sphinxcontrib/autohttp/flaskqref.py b/httpdomain/sphinxcontrib/autohttp/flaskqref.py
index 3a70b4b..8f33d18 100644
--- a/httpdomain/sphinxcontrib/autohttp/flaskqref.py
+++ b/httpdomain/sphinxcontrib/autohttp/flaskqref.py
@@ -74,6 +74,5 @@ def run(self):
return node.children
def setup(app):
- httpdomain.setup(app)
+ app.setup_extension('sphinxcontrib.httpdomain')
app.add_directive('qrefflask', QuickReferenceFlaskDirective)
-
diff --git a/httpdomain/sphinxcontrib/autohttp/tornado.py b/httpdomain/sphinxcontrib/autohttp/tornado.py
index 8efd343..f844305 100644
--- a/httpdomain/sphinxcontrib/autohttp/tornado.py
+++ b/httpdomain/sphinxcontrib/autohttp/tornado.py
@@ -123,5 +123,5 @@ def run(self):
def setup(app):
- httpdomain.setup(app)
+ app.setup_extension('sphinxcontrib.httpdomain')
app.add_directive('autotornado', AutoTornadoDirective)
diff --git a/httpdomain/sphinxcontrib/httpdomain.py b/httpdomain/sphinxcontrib/httpdomain.py
index 6a25e2e..faa50f2 100644
--- a/httpdomain/sphinxcontrib/httpdomain.py
+++ b/httpdomain/sphinxcontrib/httpdomain.py
@@ -756,13 +756,6 @@ def content_callback(self, match):
def setup(app):
- try:
- if app.registry.has_domain(HTTPDomain.name):
- return
- except AttributeError:
- if HTTPDomain.name in app.domains:
- return
-
app.add_domain(HTTPDomain)
try:
--
2.9.4

View File

@ -1,7 +1,7 @@
From bca04322b420cca6d8d7956d5c8a430d65e6aac5 Mon Sep 17 00:00:00 2001
From 1f6c4251d23ba6117943440bc1e3f43fe691da3a Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Sun, 27 Sep 2015 20:21:49 +1000
Subject: [PATCH] httpdomain: bump domain data version
Subject: [PATCH 4/4] httpdomain: bump domain data version
Upstream should have bumped this to 1 (or something greater than 0) for
the 1.4.0 release since the expected contents of the data dict changed.
@ -12,10 +12,10 @@ properly in a future upstream release.
1 file changed, 1 insertion(+)
diff --git a/httpdomain/sphinxcontrib/httpdomain.py b/httpdomain/sphinxcontrib/httpdomain.py
index d7cdcc9..c8f6850 100644
index faa50f2..27f5871 100644
--- a/httpdomain/sphinxcontrib/httpdomain.py
+++ b/httpdomain/sphinxcontrib/httpdomain.py
@@ -627,6 +627,7 @@ class HTTPDomain(Domain):
@@ -628,6 +628,7 @@ class HTTPDomain(Domain):
'copy': {},
'any': {}
}
@ -24,5 +24,5 @@ index d7cdcc9..c8f6850 100644
indices = [HTTPIndex]
--
2.4.3
2.9.4

View File

@ -3,12 +3,17 @@
Name: python-%{upstream_name}
Version: 1.5.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Sphinx domain for documenting HTTP APIs
License: BSD
URL: http://packages.python.org/sphinxcontrib-httpdomain/
Source0: https://files.pythonhosted.org/packages/source/s/%{upstream_name}/%{upstream_name}-%{version}.tar.gz
Patch1: 0001-httpdomain-bump-domain-data-version.patch
# https://bitbucket.org/birkenfeld/sphinx-contrib/pull-requests/152
Patch1: 0001-Update-http-domain-detection-to-work-with-new-Sphinx.patch
Patch2: 0002-httpdomain-Add-missing-call-to-add_domain.patch
Patch3: 0003-httpdomain-autohttp-Use-app.setup_extension.patch
# issue to be filed(?)
Patch4: 0004-httpdomain-bump-domain-data-version.patch
BuildArch: noarch
%description
@ -56,6 +61,9 @@ for generating documentation from Flask routing tables.
%prep
%setup -q -n %{upstream_name}-%{version}
%patch1 -p2
%patch2 -p2
%patch3 -p2
%patch4 -p2
rm -r *.egg-info
%build
@ -83,6 +91,9 @@ rm -r *.egg-info
%endif
%changelog
* Mon Jul 24 2017 Dan Callaghan <dcallagh@redhat.com> - 1.5.0-4
- fix for Sphinx 1.6 compatibility (RHBZ#1473447)
* Fri Jun 23 2017 Dan Callaghan <dcallagh@redhat.com> - 1.5.0-3
- added Python 3 subpackage (RHBZ#1459474)