mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Intersphinx: parse inventories correctly when object names contain embedded spaces.
This is an issue, e.g., for (multi-word) glossary terms.
This commit is contained in:
parent
64593b946e
commit
743521d55b
@ -30,6 +30,7 @@ import codecs
|
||||
import urllib2
|
||||
import posixpath
|
||||
from os import path
|
||||
import re
|
||||
|
||||
from docutils import nodes
|
||||
|
||||
@ -99,7 +100,12 @@ def read_inventory_v2(f, uri, join, bufsize=16*1024):
|
||||
assert not buf
|
||||
|
||||
for line in split_lines(read_chunks()):
|
||||
name, type, prio, location, dispname = line.rstrip().split(None, 4)
|
||||
# be careful to handle names with embedded spaces correctly
|
||||
m = re.match(r'(?x)(.+?)\s+(\S*:\S*)\s+(\S+)\s+(\S+)\s+(.*)',
|
||||
line.rstrip())
|
||||
if not m:
|
||||
continue
|
||||
name, type, prio, location, dispname = m.groups()
|
||||
if location.endswith(u'$'):
|
||||
location = location[:-1] + name
|
||||
location = join(uri, location)
|
||||
|
@ -43,6 +43,7 @@ module1 py:module 0 foo.html#module-module1 Long Module desc
|
||||
module2 py:module 0 foo.html#module-$ -
|
||||
module1.func py:function 1 sub/foo.html#$ -
|
||||
CFunc c:function 2 cfunc.html#CFunc -
|
||||
a term std:term -1 glossary.html#term-a-term -
|
||||
'''.encode('utf-8'))
|
||||
|
||||
|
||||
@ -76,6 +77,8 @@ def test_read_inventory_v2():
|
||||
assert invdata1['py:function']['module1.func'][2] == \
|
||||
'/util/sub/foo.html#module1.func'
|
||||
assert invdata1['c:function']['CFunc'][2] == '/util/cfunc.html#CFunc'
|
||||
assert invdata1['std:term']['a term'][2] == \
|
||||
'/util/glossary.html#term-a-term'
|
||||
|
||||
|
||||
@with_app(confoverrides={'extensions': 'sphinx.ext.intersphinx'})
|
||||
|
Loading…
Reference in New Issue
Block a user