From 3318aa4bbc9c2268602db404a13c9da1a7e887ef Mon Sep 17 00:00:00 2001 From: Harshitha Prabhuswamy <112987691+HarshithaPrabhuswamy@users.noreply.github.com> Date: Thu, 9 Jan 2025 08:19:08 +0100 Subject: [PATCH] Add mybinder badge in documentation when based on Jupyter Notebook (#218) - 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. --- docs/conf.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index efb4a3a..ab6d4cb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 @@ -184,7 +185,23 @@ - +
+ This page was generated from + {{ docname|e }}. + Interactive online version: + Binder badge. + Download notebook. +
+ +.. only:: latex + + .. raw:: latex + + \nbsphinxstartnotebook{\scriptsize\noindent\strut + \textcolor{gray}{The following section was generated from + \sphinxcode{\sphinxupquote{\strut {{ docname | escape_latex }}}} \dotfill}} + + """ if os.environ.get("IS_RTD", False):