From 35e10b6a304c57d0ef4c643f45b09f3169272e8c Mon Sep 17 00:00:00 2001 From: Brigitta Sipocz Date: Tue, 19 Aug 2014 18:56:47 +0100 Subject: [PATCH 1/4] #1537: Adding the option of multiple inv for the same name & uri --- sphinx/ext/intersphinx.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 6dcd3ea13..76866a562 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -179,19 +179,24 @@ def load_mappings(app): # we can safely assume that the uri<->inv mapping is not changed # during partial rebuilds since a changed intersphinx_mapping # setting will cause a full environment reread - if not inv: - inv = posixpath.join(uri, INVENTORY_FILENAME) - # decide whether the inventory must be read: always read local - # files; remote ones only if the cache time is expired - if '://' not in inv or uri not in cache \ - or cache[uri][1] < cache_time: - app.info('loading intersphinx inventory from %s...' % inv) - invdata = fetch_inventory(app, uri, inv) - if invdata: - cache[uri] = (name, now, invdata) - else: - cache.pop(uri, None) - update = True + if not isinstance(inv, tuple): + invs = (inv, ) + else: + invs = inv + + for inv in invs: + if not inv: + inv = posixpath.join(uri, INVENTORY_FILENAME) + # decide whether the inventory must be read: always read local + # files; remote ones only if the cache time is expired + if '://' not in inv or uri not in cache \ + or cache[uri][1] < cache_time: + app.info('loading intersphinx inventory from %s...' % inv) + invdata = fetch_inventory(app, uri, inv) + if invdata: + cache[uri] = (name, now, invdata) + update = True + if update: env.intersphinx_inventory = {} env.intersphinx_named_inventory = {} From 6617e7cf08f0588310488e89954b539faedc3718 Mon Sep 17 00:00:00 2001 From: Brigitta Sipocz Date: Tue, 19 Aug 2014 20:12:45 +0100 Subject: [PATCH 2/4] fix indent --- sphinx/ext/intersphinx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 76866a562..fa8443538 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -195,7 +195,7 @@ def load_mappings(app): invdata = fetch_inventory(app, uri, inv) if invdata: cache[uri] = (name, now, invdata) - update = True + update = True if update: env.intersphinx_inventory = {} From 452f59af0edc638e567c1f0cdb49a6296f7addb1 Mon Sep 17 00:00:00 2001 From: Brigitta Sipocz Date: Thu, 21 Aug 2014 12:47:32 +0100 Subject: [PATCH 3/4] Addressing comment and adding docs --- doc/ext/intersphinx.rst | 12 ++++++++++++ sphinx/ext/intersphinx.py | 1 + 2 files changed, 13 insertions(+) diff --git a/doc/ext/intersphinx.rst b/doc/ext/intersphinx.rst index b3972b431..1cf4735e8 100644 --- a/doc/ext/intersphinx.rst +++ b/doc/ext/intersphinx.rst @@ -102,6 +102,18 @@ linking: ``http://docs.python.org/3.2``. It is up to you to update the inventory file as new objects are added to the Python documentation. + .. versionadded:: 1.3 + + Alternative files can be specified for each inventory. One can give a + tuple for the second inventory tuple item as shown in the following + example. This will read the inventory iterating through the (second) + tuple items until the first successful fetch. The primary use case for + this to specify mirror sites for server downtime of the primary + inventory:: + + intersphinx_mapping = {'python': ('http://docs.python.org/3.2', + (None, 'python-inv.txt')} + .. confval:: intersphinx_cache_limit The maximum number of days to cache remote inventories. The default is diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index fa8443538..320a9eb4c 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -196,6 +196,7 @@ def load_mappings(app): if invdata: cache[uri] = (name, now, invdata) update = True + break if update: env.intersphinx_inventory = {} From 64b915bdbe56a55fce6b6c61e0c6d3be5d85334b Mon Sep 17 00:00:00 2001 From: Brigitta Sipocz Date: Thu, 21 Aug 2014 12:50:21 +0100 Subject: [PATCH 4/4] fix typo --- doc/ext/intersphinx.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ext/intersphinx.rst b/doc/ext/intersphinx.rst index 1cf4735e8..d267c5992 100644 --- a/doc/ext/intersphinx.rst +++ b/doc/ext/intersphinx.rst @@ -112,7 +112,7 @@ linking: inventory:: intersphinx_mapping = {'python': ('http://docs.python.org/3.2', - (None, 'python-inv.txt')} + (None, 'python-inv.txt'))} .. confval:: intersphinx_cache_limit