summaryrefslogtreecommitdiff
path: root/doc/conf.py
diff options
context:
space:
mode:
authorMatthias Geier <Matthias.Geier@gmail.com>2020-07-07 21:02:31 +0200
committerMatthias Geier <Matthias.Geier@gmail.com>2020-07-07 21:13:07 +0200
commit4bb8ef9c1c6b999d84bf69799215b7054958ec85 (patch)
treec03a50e8dff34931fbed6ef2018e79b2c654060f /doc/conf.py
parent5c1a9de051cfa6b72bf26923c37a43c5ee5a0a59 (diff)
DOC: gh-example role
Diffstat (limited to 'doc/conf.py')
-rw-r--r--doc/conf.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/conf.py b/doc/conf.py
index 9f3438e..79491cf 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -75,3 +75,19 @@ latex_elements = {
latex_documents = [('index', 'python-sounddevice.tex', project, authors, 'howto')]
latex_show_urls = 'footnote'
latex_domain_indices = False
+
+
+def gh_example_role(rolename, rawtext, text, lineno, inliner,
+ options={}, content=()):
+ from docutils import nodes, utils
+ github_url = 'https://github.com/spatialaudio/python-sounddevice'
+ base_url = github_url + '/blob/' + release + '/examples/%s'
+ text = utils.unescape(text)
+ full_url = base_url % text
+ pnode = nodes.reference(internal=False, refuri=full_url)
+ pnode += nodes.literal(text, text, classes=['file'])
+ return [pnode], []
+
+
+def setup(app):
+ app.add_role('gh-example', gh_example_role)