Skip to content

Commit

Permalink
add definitions of markdown badges
Browse files Browse the repository at this point in the history
  • Loading branch information
AgnieszkaZaba committed Oct 12, 2024
1 parent 1ff408a commit dcb2c4c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,28 @@ def test_jetbrains_bug_py_66491(notebook_filename):
!pip --quiet install open-atmos-jupyter-utils
from open_atmos_jupyter_utils import pip_install_on_colab
pip_install_on_colab('PySDM-examples')"""


def _relative_path(absolute_path):
return os.path.relpath(
absolute_path,
pathlib.Path(__file__).parent.parent.parent.absolute()
)

def _nbviewer_badge_markdown(absolute_path):
svg_badge_url = "https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg"
link = f"https://nbviewer.jupyter.org/github/open-atmos/PySDM/blob/main/{_relative_path(absolute_path)}"
return f"[![preview in nbviewer]({svg_badge_url})]({link})"

def _mybinder_badge_markdown(abslute_path):
svg_badge_url = "https://mybinder.org/badge_logo.svg"
link = f"https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=lab/tree/{_relative_path(abslute_path)}"
return f"[![launch on mybinder.org]({svg_badge_url})]({link})"

def _colab_badge_markdown(absolute_path):
svg_badge_url = "https://colab.research.google.com/assets/colab-badge.svg"
link = f"https://colab.research.google.com/github/open-atmos/PySDM/blob/main/{_relative_path(absolute_path)}"
return f"[![launch on Colab]({svg_badge_url})]({link})"

def test_first_cell_contains_three_badges(notebook):
""" checks if all notebooks feature nbviewer, mybinder and Colab badges (in the first cell) """
with open(notebook) as fp:
Expand Down

0 comments on commit dcb2c4c

Please sign in to comment.