Skip to content

Commit

Permalink
add bash script for badges generation in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlunin committed Dec 11, 2024
1 parent 36b5e4f commit 70a778f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ jobs:
run: |
echo "current jupyter-notebook: ${{ matrix.notebook }}"
- name: Add colab and download badges
run: |
# get name of the notebook
notebook=${{ matrix.notebook }}
# get github repo like "username/reponame"
gh_repo="$GITHUB_REPOSITORY"
gh_ref=""
# if pull request - take the SHA of the commit
# regular reference to the pull_request is not possible
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
gh_ref=$GITHUB_SHA
# if push in the repository - take the branch name
elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
gh_ref=$(basename $GITHUB_REF)
fi
# in the pr #537 the $notebook variable would have the full path to the file, the "examples" folder should be deleted here
colab_url="https://colab.research.google.com/github/$gh_repo/blob/$gh_ref/examples/$notebook")
# and the for the myst only the basene for File: reference need to be taken
badges_md="[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]($colab_url) [![Download notebook](https://img.shields.io/badge/jupyter-notebook-blue?logo=jupyter)](File:$notebook)"
python_command="from nbformat as nbf; nb = nbf.read(open('examples/$notebook'), as_version=4); nb['cells'].insert(0, nbf.v4.new_markdown_cell($badges_md); nbf.write(nb, open('examples/$notebook', 'w'))"
python -c "$python_command"
- name: Run notebook
uses: fzimmermann89/run-notebook@v3
env:
Expand Down
1 change: 0 additions & 1 deletion examples/direct_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# %% [markdown]
# # Direct Reconstruction of 2D golden angle radial data
# Here we use the DirectReconstruction class to reconstruct images from ISMRMRD 2D radial data

# %%
# define zenodo URL of the example ismrmd data
zenodo_url = 'https://zenodo.org/records/10854057/files/'
Expand Down

0 comments on commit 70a778f

Please sign in to comment.