import importlib
import os.path
from urlparse import urlunsplit
-import sphinx
def setup(app):
app.add_config_value('github_user', None, 'env')
if not app.config.github_user and app.config.github_project:
return
- def github_doc_link(mode='blob'):
- """ returns the github URL for the current page
-
- :param str mode: 'edit' for edition view
- """
- return make_github_link(
- app,
- 'doc/%s%s' % (pagename, app.config.source_suffix),
- mode=mode)
- context['github_link'] = github_doc_link
+ # can't use functools.partial because 3rd positional is line not mode
+ context['github_link'] = lambda mode='mode': make_github_link(
+ app, 'doc/%s%s' % (pagename, app.config.source_suffix), mode=mode)
{{ toctree(maxdepth=4, collapse=False, includehidden=True,
main_navbar=False, titles_only=False) }}
{% if github_link %}
- <p><a href="{{ github_link() }}" class="github">
- View on GitHub
+ <p><a href="{{ github_link(mode='edit') }}" class="github">
+ Edit on GitHub
</a></p>
{% endif %}
</div>