mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #2056 from erosennin/intersphinx-fix-relative-path
Fix relative paths in intersphinx links
This commit is contained in:
commit
c832d36d19
@ -332,7 +332,7 @@ def missing_reference(app, env, node, contnode):
|
|||||||
proj, version, uri, dispname = inventory[objtype][target]
|
proj, version, uri, dispname = inventory[objtype][target]
|
||||||
if '://' not in uri and node.get('refdoc'):
|
if '://' not in uri and node.get('refdoc'):
|
||||||
# get correct path in case of subdirectories
|
# 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,
|
newnode = nodes.reference('', '', internal=False, refuri=uri,
|
||||||
reftitle=_('(in %s v%s)') % (proj, version))
|
reftitle=_('(in %s v%s)') % (proj, version))
|
||||||
if node.get('refexplicit'):
|
if node.get('refexplicit'):
|
||||||
|
@ -134,6 +134,8 @@ def test_missing_reference(tempdir, app, status, warning):
|
|||||||
app.config.intersphinx_mapping = {
|
app.config.intersphinx_mapping = {
|
||||||
'https://docs.python.org/': inv_file,
|
'https://docs.python.org/': inv_file,
|
||||||
'py3k': ('https://docs.python.org/py3k/', 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
|
app.config.intersphinx_cache_limit = 0
|
||||||
|
|
||||||
@ -201,6 +203,19 @@ def test_missing_reference(tempdir, app, status, warning):
|
|||||||
assert rn is None
|
assert rn is None
|
||||||
assert contnode[0].astext() == 'py3k:unknown'
|
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_app()
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
|
Loading…
Reference in New Issue
Block a user