Skip to content

Commit

Permalink
Add mybinder badge in documentation when based on Jupyter Notebook (#218
Browse files Browse the repository at this point in the history
)

- Updated `nbsphinx_prolog` in `conf.py` to include GitHub, Binder, and download options for each notebook.
- Enabled interactive version of notebooks on MyBinder.
- Updated the GitHub repository link in the `conf.py` file to ensure proper generation of interactive MyBinder links for all notebooks.
- Verified the syntax and placeholders to avoid URL generation errors.
  • Loading branch information
HarshithaPrabhuswamy authored Jan 9, 2025
1 parent f5f6554 commit 3318aa4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@

# -- Style nbsphinx notebook rendering ----------------------------------------

nbsphinx_prolog = """
nbsphinx_prolog = r"""
{% set docname = 'docs/' + env.doc2path(env.docname, base=None)|string %}
.. raw:: html
<!-- nbsphinx prolog - start -->
Expand Down Expand Up @@ -184,7 +185,23 @@
</style>
<!-- nbsphinx prolog - end -->
<div class="admonition note">
This page was generated from
<a class="reference external" href="https://github.com/1kastner/conflowgen/blob/main{{ env.config.release|e }}/{{ docname|e }}">{{ docname|e }}</a>.
Interactive online version:
<span style="white-space: nowrap;"><a href="https://mybinder.org/v2/gh/1kastner/conflowgen/main{{ env.config.release|e }}?filepath={{ docname|e }}"><img alt="Binder badge" src="https://mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a>.</span>
<a href="{{ env.docname.split('/')|last|e + '.ipynb' }}" class="reference download internal" download>Download notebook</a>.
</div>
.. only:: latex
.. raw:: latex
\nbsphinxstartnotebook{\scriptsize\noindent\strut
\textcolor{gray}{The following section was generated from
\sphinxcode{\sphinxupquote{\strut {{ docname | escape_latex }}}} \dotfill}}
<!-- nbsphinx prolog - end -->
"""

if os.environ.get("IS_RTD", False):
Expand Down

0 comments on commit 3318aa4

Please sign in to comment.