|
8 | 8 | import os
|
9 | 9 | import warnings
|
10 | 10 |
|
11 |
| - |
12 |
| -__licence__ = 'BSD (3 clause)' |
| 11 | +__licence__ = "BSD (3 clause)" |
13 | 12 |
|
14 | 13 |
|
15 | 14 | def get_github_url(app, view, path):
|
16 |
| - return 'https://github.com/{project}/{view}/{branch}/{path}'.format( |
| 15 | + return "https://github.com/{project}/{view}/{branch}/{path}".format( |
17 | 16 | project=app.config.edit_on_github_project,
|
18 | 17 | view=view,
|
19 | 18 | branch=app.config.edit_on_github_branch,
|
20 |
| - path=path) |
| 19 | + path=path, |
| 20 | + ) |
21 | 21 |
|
22 | 22 |
|
23 | 23 | def html_page_context(app, pagename, templatename, context, doctree):
|
24 |
| - if templatename != 'page.html': |
| 24 | + if templatename != "page.html": |
25 | 25 | return
|
26 | 26 |
|
27 | 27 | if not app.config.edit_on_github_project:
|
28 | 28 | warnings.warn("edit_on_github_project not specified")
|
29 | 29 | return
|
30 | 30 |
|
31 |
| - path = os.path.relpath(doctree.get('source'), app.builder.srcdir) |
32 |
| - show_url = get_github_url(app, 'blob', path) |
33 |
| - edit_url = get_github_url(app, 'edit', path) |
| 31 | + path = os.path.relpath(doctree.get("source"), app.builder.srcdir) |
| 32 | + show_url = get_github_url(app, "blob", path) |
| 33 | + edit_url = get_github_url(app, "edit", path) |
34 | 34 |
|
35 |
| - context['show_on_github_url'] = show_url |
36 |
| - context['edit_on_github_url'] = edit_url |
| 35 | + context["show_on_github_url"] = show_url |
| 36 | + context["edit_on_github_url"] = edit_url |
37 | 37 |
|
38 | 38 |
|
39 | 39 | def setup(app):
|
40 |
| - app.add_config_value('edit_on_github_project', '', True) |
41 |
| - app.add_config_value('edit_on_github_branch', 'master', True) |
42 |
| - app.connect('html-page-context', html_page_context) |
| 40 | + app.add_config_value("edit_on_github_project", "", True) |
| 41 | + app.add_config_value("edit_on_github_branch", "master", True) |
| 42 | + app.connect("html-page-context", html_page_context) |
0 commit comments