[IMP] doc: link directly to edition mode in docfiles
This commit is contained in:
parent
63e1afc5fd
commit
95265e9ba6
|
@ -2,7 +2,6 @@ import inspect
|
||||||
import importlib
|
import importlib
|
||||||
import os.path
|
import os.path
|
||||||
from urlparse import urlunsplit
|
from urlparse import urlunsplit
|
||||||
import sphinx
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_config_value('github_user', None, 'env')
|
app.add_config_value('github_user', None, 'env')
|
||||||
|
@ -73,13 +72,6 @@ def add_doc_link(app, pagename, templatename, context, doctree):
|
||||||
if not app.config.github_user and app.config.github_project:
|
if not app.config.github_user and app.config.github_project:
|
||||||
return
|
return
|
||||||
|
|
||||||
def github_doc_link(mode='blob'):
|
# can't use functools.partial because 3rd positional is line not mode
|
||||||
""" returns the github URL for the current page
|
context['github_link'] = lambda mode='mode': make_github_link(
|
||||||
|
app, 'doc/%s%s' % (pagename, app.config.source_suffix), mode=mode)
|
||||||
: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
|
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
{{ toctree(maxdepth=4, collapse=False, includehidden=True,
|
{{ toctree(maxdepth=4, collapse=False, includehidden=True,
|
||||||
main_navbar=False, titles_only=False) }}
|
main_navbar=False, titles_only=False) }}
|
||||||
{% if github_link %}
|
{% if github_link %}
|
||||||
<p><a href="{{ github_link() }}" class="github">
|
<p><a href="{{ github_link(mode='edit') }}" class="github">
|
||||||
View on GitHub
|
Edit on GitHub
|
||||||
</a></p>
|
</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue