Skip to content

Instantly share code, notes, and snippets.

@abitrolly
Created January 8, 2019 21:38
Show Gist options
  • Save abitrolly/12522b399c92606d7b09e9342c3f788b to your computer and use it in GitHub Desktop.
Save abitrolly/12522b399c92606d7b09e9342c3f788b to your computer and use it in GitHub Desktop.
Sphinx template override to link "View Source" to code repository
<!--
1. Place this to _templates/layout.html
2. Edit source_url_prefix below to point to your repo
Overriding Alabaster Theme to replace link to static page source
with a link to GitHub. Using instructions from official guide.
https://www.sphinx-doc.org/en/master/templating.html#jinja-sphinx-templating-primer
-->
{% set source_url_prefix = 'https://github.com/bitprophet/alabaster/tree/master/docs' %}
{% extends "!layout.html" %}
{%- block footer %}
<div class="footer" style="text-align: center">
&copy;{{ copyright }}.|
Powered by <a href="http://sphinx-doc.org/">Sphinx {{ sphinx_version }}</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster {{ alabaster_version }}</a>
(<a href="{{ source_url_prefix }}/_templates">customized</a>)
|
<a href="{{ source_url_prefix }}{{ pagename + ".rst"|e }}"
rel="nofollow">{{ _('View source') }}</a>
</div>
{%- endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment