Merge branch 'stable' into 1.7-release

This commit is contained in:
Takeshi KOMIYA
2018-02-03 02:14:06 +09:00
5 changed files with 63 additions and 7 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@
.cache/
.idea
.mypy_cache/
.pytest_cache/
.ropeproject/
TAGS
.tags

View File

@@ -232,6 +232,9 @@ Bugs fixed
* #3917: citation labels are tranformed to ellipsis
* #4501: graphviz: epub3 validation error caused if graph is not clickable
* #4514: graphviz: workaround for wrong map ID which graphviz generates
* #4525: autosectionlabel does not support parallel build
* #3953: Do not raise warning when there is a working intersphinx inventory
* #4487: math: ValueError is raised on parallel build. Thanks to jschueller.
Testing
--------

View File

@@ -178,9 +178,9 @@ def fetch_inventory(app, uri, inv):
else:
f = open(path.join(app.srcdir, inv), 'rb')
except Exception as err:
logger.warning('intersphinx inventory %r not fetchable due to %s: %s',
inv, err.__class__, err)
return
err.args = ('intersphinx inventory %r not fetchable due to %s: %s',
inv, err.__class__, err)
raise
try:
if hasattr(f, 'url'):
newinv = f.url # type: ignore
@@ -196,8 +196,9 @@ def fetch_inventory(app, uri, inv):
except ValueError as exc:
raise ValueError('unknown or unsupported inventory version: %r' % exc)
except Exception as err:
logger.warning('intersphinx inventory %r not readable due to %s: %s',
inv, err.__class__.__name__, err)
err.args = ('intersphinx inventory %r not readable due to %s: %s',
inv, err.__class__.__name__, err)
raise
else:
return invdata
@@ -231,6 +232,7 @@ def load_mappings(app):
else:
invs = inv # type: ignore
failures = []
for inv in invs:
if not inv:
inv = posixpath.join(uri, INVENTORY_FILENAME)
@@ -240,12 +242,30 @@ def load_mappings(app):
or inventories.cache[uri][1] < cache_time:
safe_inv_url = _get_safe_url(inv) # type: ignore
logger.info('loading intersphinx inventory from %s...', safe_inv_url)
invdata = fetch_inventory(app, uri, inv)
try:
invdata = fetch_inventory(app, uri, inv)
except Exception as err:
failures.append(err.args)
continue
if invdata:
inventories.cache[uri] = (name, now, invdata)
update = True
break
if failures == []:
pass
elif len(failures) < len(invs):
logger.info("encountered some issues with some of the inventories,"
" but they had working alternatives:")
for fail in failures:
logger.info(*fail)
else:
logger.warning("failed to reach any of the inventories "
"with the following issues:")
for fail in failures:
logger.warning(*fail)
if update:
inventories.clear()

View File

@@ -72,7 +72,7 @@ class MathDomain(Domain):
# type: (Iterable[unicode], Dict) -> None
for labelid, (doc, eqno) in otherdata['objects'].items():
if doc in docnames:
self.data['objects'][labelid] = doc
self.data['objects'][labelid] = (doc, eqno)
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
# type: (BuildEnvironment, unicode, Builder, unicode, unicode, nodes.Node, nodes.Node) -> nodes.Node # NOQA

View File

@@ -312,6 +312,38 @@ def test_load_mappings_warnings(tempdir, app, status, warning):
assert warning.getvalue().count('\n') == 1
def test_load_mappings_fallback(tempdir, app, status, warning):
inv_file = tempdir / 'inventory'
inv_file.write_bytes(inventory_v2)
app.config.intersphinx_cache_limit = 0
# connect to invalid path
app.config.intersphinx_mapping = {
'fallback': ('https://docs.python.org/py3k/', '/invalid/inventory/path'),
}
load_mappings(app)
assert "failed to reach any of the inventories" in warning.getvalue()
rn = reference_check(app, 'py', 'func', 'module1.func', 'foo')
assert rn is None
# clear messages
status.truncate(0)
warning.truncate(0)
# add fallbacks to mapping
app.config.intersphinx_mapping = {
'fallback': ('https://docs.python.org/py3k/', ('/invalid/inventory/path',
inv_file)),
}
load_mappings(app)
assert "encountered some issues with some of the inventories" in status.getvalue()
assert "" == warning.getvalue()
rn = reference_check(app, 'py', 'func', 'module1.func', 'foo')
assert isinstance(rn, nodes.reference)
class TestStripBasicAuth(unittest.TestCase):
"""Tests for sphinx.ext.intersphinx._strip_basic_auth()"""
def test_auth_stripped(self):