diff --git a/sphinx_rtd_theme/breadcrumbs.html b/sphinx_rtd_theme/breadcrumbs.html index bd45b6d7c..a76298085 100644 --- a/sphinx_rtd_theme/breadcrumbs.html +++ b/sphinx_rtd_theme/breadcrumbs.html @@ -17,6 +17,7 @@ {%- endif %} {%- set display_vcs_links = display_vcs_links if display_vcs_links is defined else True %} +{%- set has_source_page = pagename not in ['genindex', 'search'] %} {#- Translators: This is an ARIA section label for page links, including previous/next page link and links to GitHub/GitLab/etc. -#}
@@ -30,7 +31,7 @@ {%- endblock %} {%- block breadcrumbs_aside %}
  • - {%- if hasdoc(pagename) and display_vcs_links %} + {%- if hasdoc(pagename) and has_source_page and display_vcs_links %} {%- if display_github %} {%- if check_meta and 'github_url' in meta %} diff --git a/tests/test_builders.py b/tests/test_builders.py index c66d23389..f117e5459 100644 --- a/tests/test_builders.py +++ b/tests/test_builders.py @@ -13,7 +13,7 @@ SingleFileHTMLBuilder, ) -from .util import build_all +from .util import build, build_all def test_basic(): @@ -66,6 +66,34 @@ def test_basic(): .format(app.builder.name)) +def test_edit_links_are_skipped_for_generated_pages(): + html_context = { + 'display_github': True, + 'github_user': 'readthedocs', + 'github_repo': 'sphinx_rtd_theme', + 'github_version': 'master/', + 'conf_py_path': 'tests/roots/test-basic/', + } + + with build('test-basic', confoverrides={'html_context': html_context}) as ( + app, + _status, + _warning, + ): + content = open( + os.path.join(app.outdir, 'index.html'), + encoding='utf-8', + ).read() + assert 'Edit on GitHub' in content + + for filename in ['genindex.html', 'search.html']: + content = open( + os.path.join(app.outdir, filename), + encoding='utf-8', + ).read() + assert 'Edit on GitHub' not in content + + def test_empty(): """Local TOC is showing, as toctree was empty""" for (app, status, warning) in build_all('test-empty'):