mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Set its URL as a default title value if URL appears in toctree
This commit is contained in:
parent
60911efe05
commit
7db168416b
@ -1217,6 +1217,8 @@ class BuildEnvironment:
|
||||
try:
|
||||
refdoc = None
|
||||
if url_re.match(ref):
|
||||
if title is None:
|
||||
title = ref
|
||||
reference = nodes.reference('', '', internal=False,
|
||||
refuri=ref, anchorname='',
|
||||
*[nodes.Text(title)])
|
||||
|
@ -459,3 +459,18 @@ def test_tocdepth_singlehtml(app):
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@with_app(buildername='html', srcdir='(empty)')
|
||||
def test_url_in_toctree(app):
|
||||
contents = (".. toctree::\n"
|
||||
"\n"
|
||||
" http://sphinx-doc.org/\n"
|
||||
" Latest reference <http://sphinx-doc.org/latest/>\n")
|
||||
|
||||
(app.srcdir / 'contents.rst').write_text(contents, encoding='utf-8')
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'contents.html').text(encoding='utf-8')
|
||||
assert '<a class="reference external" href="http://sphinx-doc.org/">http://sphinx-doc.org/</a>' in result
|
||||
assert '<a class="reference external" href="http://sphinx-doc.org/latest/">Latest reference</a>' in result
|
||||
|
Loading…
Reference in New Issue
Block a user