diff options
author | Takayuki Shimizukawa <shimizukawa+bitbucket@gmail.com> | 2014-08-20 06:14:15 +0900 |
---|---|---|
committer | Takayuki Shimizukawa <shimizukawa+bitbucket@gmail.com> | 2014-08-20 06:14:15 +0900 |
commit | 54c42cc2669ddaa5be2ceadb8eb8d0e94f3d8751 (patch) | |
tree | 172b81ad68bf913867d9c3090965c0581f61d9dc | |
parent | 13f3f51a47a0430d1161e5283038d31c94d3ea04 (diff) | |
parent | 57a50adf73e4fa1c15e51bf21896e697674be463 (diff) | |
download | sphinx-54c42cc2669ddaa5be2ceadb8eb8d0e94f3d8751.tar.gz |
Merged in tk0miya/sphinx (pull request #274)
Set its URL as a default title value if URL appears in toctree
-rw-r--r-- | sphinx/environment.py | 2 | ||||
-rw-r--r-- | tests/test_build_html.py | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/sphinx/environment.py b/sphinx/environment.py index 85e832cc..6d2a5f2a 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -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)]) diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 3753d05b..2c5f291e 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -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 |