Skip to content

Commit

Permalink
RTD: Add run-in-binder links to notebooks (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Jan 17, 2023
1 parent de1ba7e commit b58a005
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ def install_doxygen():
'python': ('https://docs.python.org/3', None),
}

# Add notebooks prolog with binder links
# get current git reference
ret = subprocess.run(
"git rev-parse HEAD".split(" "),
capture_output=True
)
ref = ret.stdout.rstrip().decode()
nbsphinx_prolog = (
f"{{% set {ref=} %}}"
r"""
{% set docname = "documentation/" + env.doc2path(env.docname, base=False) %}
.. raw:: html
<div class="note">
<a href="https://mybinder.org/v2/gh/AMICI-dev/AMICI/{{ ref|e }}?labpath={{ docname|e }}" target="_blank">
<img src="https://mybinder.org/badge_logo.svg" alt="Open in binder"/></a>
</div>
"""
)

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down

0 comments on commit b58a005

Please sign in to comment.