summaryrefslogtreecommitdiff
path: root/doc/_extensions/github_link.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2018-09-25 16:23:38 +0200
committerMartin Trigaux <mat@odoo.com>2018-09-28 12:23:41 +0200
commit8eb8495710f127e5edd5a03c13ec956401300221 (patch)
tree52d42094ca9a4c4d6a1b62592e9983af47caabb2 /doc/_extensions/github_link.py
parentb18a4cba0e21c518a3f6e6c5a70acf67f9fcf669 (diff)
[FIX] doc: backport of ac37ca39e
github_link compatibility with Sphinx 1.8 Backport to 11.0
Diffstat (limited to 'doc/_extensions/github_link.py')
-rw-r--r--doc/_extensions/github_link.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/doc/_extensions/github_link.py b/doc/_extensions/github_link.py
index 155e4083025..72d51bfeb60 100644
--- a/doc/_extensions/github_link.py
+++ b/doc/_extensions/github_link.py
@@ -91,17 +91,17 @@ def make_github_link(app, path, line=None, mode="blob"):
'',
'' if line is None else 'L%d' % line
))
-
def add_doc_link(app, pagename, templatename, context, doctree):
""" Add github_link function linking to the current page on github """
if not app.config.github_user and app.config.github_project:
return
- # FIXME: find other way to recover current document's source suffix
- # in Sphinx 1.3 it's possible to have mutliple source suffixes and that
- # may be useful in the future
source_suffix = app.config.source_suffix
- source_suffix = source_suffix if isinstance(source_suffix, pycompat.string_types) else source_suffix[0]
+ # in 1.3 source_suffix can be a list
+ # in 1.8 source_suffix can be a mapping
+ # FIXME: will break if we ever add support for !rst markdown documents maybe
+ if not isinstance(source_suffix, pycompat.string_types):
+ source_suffix = next(iter(source_suffix))
# can't use functools.partial because 3rd positional is line not mode
context['github_link'] = lambda mode='edit': make_github_link(
app, 'doc/%s%s' % (pagename, source_suffix), mode=mode)