mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix relative paths in intersphinx links
This commit is contained in:
parent
b215da8250
commit
5fde902f82
@ -257,7 +257,7 @@ def missing_reference(app, env, node, contnode):
|
||||
proj, version, uri, dispname = inventory[objtype][target]
|
||||
if '://' not in uri and node.get('refdoc'):
|
||||
# get correct path in case of subdirectories
|
||||
uri = path.join(relative_path(node['refdoc'], env.srcdir), uri)
|
||||
uri = path.join(relative_path(node['refdoc'], '.'), uri)
|
||||
newnode = nodes.reference('', '', internal=False, refuri=uri,
|
||||
reftitle=_('(in %s v%s)') % (proj, version))
|
||||
if node.get('refexplicit'):
|
||||
|
@ -86,6 +86,8 @@ def test_missing_reference(tempdir, app, status, warning):
|
||||
app.config.intersphinx_mapping = {
|
||||
'https://docs.python.org/': inv_file,
|
||||
'py3k': ('https://docs.python.org/py3k/', inv_file),
|
||||
'py3krel': ('py3k', inv_file), # relative path
|
||||
'py3krelparent': ('../../py3k', inv_file), # relative path, parent dir
|
||||
}
|
||||
app.config.intersphinx_cache_limit = 0
|
||||
|
||||
@ -153,6 +155,19 @@ def test_missing_reference(tempdir, app, status, warning):
|
||||
assert rn is None
|
||||
assert contnode[0].astext() == 'py3k:unknown'
|
||||
|
||||
# check relative paths
|
||||
rn = reference_check('py', 'mod', 'py3krel:module1', 'foo')
|
||||
assert rn['refuri'] == 'py3k/foo.html#module-module1'
|
||||
|
||||
rn = reference_check('py', 'mod', 'py3krelparent:module1', 'foo')
|
||||
assert rn['refuri'] == '../../py3k/foo.html#module-module1'
|
||||
|
||||
rn = reference_check('py', 'mod', 'py3krel:module1', 'foo', refdoc='sub/dir/test')
|
||||
assert rn['refuri'] == '../../py3k/foo.html#module-module1'
|
||||
|
||||
rn = reference_check('py', 'mod', 'py3krelparent:module1', 'foo', refdoc='sub/dir/test')
|
||||
assert rn['refuri'] == '../../../../py3k/foo.html#module-module1'
|
||||
|
||||
|
||||
@with_app()
|
||||
@with_tempdir
|
||||
|
Loading…
Reference in New Issue
Block a user