From f7f20c3f5e0be02585741f5f54d198689ccd7866 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 18:27:18 +0200 Subject: Adding upstream version 8.2402.0+dfsg. Signed-off-by: Daniel Baumann --- source/_ext/edit_on_github.py | 43 +++++++++++++++++++++++++++++++++++++++++ source/_ext/edit_on_github.pyc | Bin 0 -> 1743 bytes 2 files changed, 43 insertions(+) create mode 100644 source/_ext/edit_on_github.py create mode 100644 source/_ext/edit_on_github.pyc (limited to 'source/_ext') diff --git a/source/_ext/edit_on_github.py b/source/_ext/edit_on_github.py new file mode 100644 index 0000000..a8d22c1 --- /dev/null +++ b/source/_ext/edit_on_github.py @@ -0,0 +1,43 @@ +""" +Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the +sidebar. + +Loosely based on https://github.com/astropy/astropy/pull/347 +""" + +import os +import warnings + + +__licence__ = 'BSD (3 clause)' + + +def get_github_url(app, view, path): + return 'https://github.com/{project}/{view}/{branch}/source/{path}'.format( + project=app.config.edit_on_github_project, + view=view, + branch=app.config.edit_on_github_branch, + path=path) + + +def html_page_context(app, pagename, templatename, context, doctree): + if templatename != 'page.html': + return + + if not app.config.edit_on_github_project: + warnings.warn("edit_on_github_project not specified") + return + + path = os.path.relpath(doctree.get('source'), app.builder.srcdir) + show_url = get_github_url(app, 'blob', path) + edit_url = get_github_url(app, 'edit', path) + + context['show_on_github_url'] = show_url + context['edit_on_github_url'] = edit_url + + +def setup(app): + app.add_config_value('edit_on_github_project', '', True) + app.add_config_value('edit_on_github_branch', 'master', True) + app.connect('html-page-context', html_page_context) + diff --git a/source/_ext/edit_on_github.pyc b/source/_ext/edit_on_github.pyc new file mode 100644 index 0000000..2d9b422 Binary files /dev/null and b/source/_ext/edit_on_github.pyc differ -- cgit v1.2.3