{#- Support for Sphinx 1.3+ page_source_suffix, but don't break old builds. #}
{%- if page_source_suffix %}
{%- set suffix = page_source_suffix %}
{%- else %}
{%- set suffix = source_suffix %}
{%- endif %}
{%- if meta is defined and meta is not none %}
{%- set check_meta = True %}
{%- else %}
{%- set check_meta = False %}
{%- endif %}
{%- if check_meta and 'github_url' in meta %}
{%- set display_github = True %}
{%- endif %}
{%- if check_meta and 'bitbucket_url' in meta %}
{%- set display_bitbucket = True %}
{%- endif %}
{%- if check_meta and 'gitlab_url' in meta %}
{%- set display_gitlab = True %}
{%- endif %}
{%- set display_vcs_links = display_vcs_links if display_vcs_links is defined else True %}
{%- if hasdoc(pagename) and display_vcs_links %}
{%- if display_github %}
{%- if check_meta and 'github_url' in meta %}
{{ _('Edit on GitHub') }}
{%- else %}
{{ _('Edit on GitHub') }}
{%- endif %}
{%- elif display_bitbucket %}
{%- if check_meta and 'bitbucket_url' in meta %}
{{ _('Edit on Bitbucket') }}
{%- else %}
{{ _('Edit on Bitbucket') }}
{%- endif %}
{%- elif display_gitlab %}
{%- if check_meta and 'gitlab_url' in meta %}
{{ _('Edit on GitLab') }}
{%- else %}
{{ _('Edit on GitLab') }}
{%- endif %}
{%- elif show_source and source_url_prefix %}
{{ _('Show source') }}
{%- elif show_source and has_source and sourcename %}
{{ _('Show source') }}
{%- endif %}
{%- endif %}