Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
attempt to get jupyter book running
Browse files Browse the repository at this point in the history
  • Loading branch information
kandersolar committed Mar 19, 2024
1 parent a5f668c commit 524cd1c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
pip install -r requirements.txt
pip install jupyter-book
- name: Preprocess attachments
run: |
python .github/workflows/preprocess-notebook-attachments.py
# Build the book
- name: Build the book
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/preprocess-notebook-attachments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# from https://github.com/executablebooks/jupyter-book/issues/1087#issuecomment-1969119486

import base64
import json
import glob

filenames = glob.glob('*ipynb')

for fn in filenames:
with open(fn) as f:
nb = json.load(f)

attachments = [cell.get('attachments') for cell in nb['cells']]
attachments = [a for a in attachments if a]

for attachment in attachments:
for name, data in attachment.items():
for filetype, encoded in data.items():
print(f'{name} ({filetype})')
img_data = base64.b64decode(encoded)
with open(f'attachment:{name}', 'wb') as img:
img.write(img_data)
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ only_build_toc_files: false
# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: auto
execute_notebooks: 'off'

# Define the name of the latex output file for PDF builds
latex:
Expand Down
7 changes: 5 additions & 2 deletions _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Learn more at https://jupyterbook.org/customize/toc.html

format: jb-book
root: Tutorial 0 - Overview
root: README
chapters:
- file: Tutorial 1 -
- file: pvanalytics-slideshow
- file: RdTools tutorial
- file: rdtools-availability
- file: solar-data-tools-demo

0 comments on commit 524cd1c

Please sign in to comment.