126 lines
4.4 KiB
Diff
126 lines
4.4 KiB
Diff
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
|
|
|