-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
43 lines (33 loc) · 980 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true
require 'rake/clean'
task default: :convert
# Quarto
qmd_dir = 'doc/qmd'
notebook_dir = 'doc/notebook'
directory notebook_dir
qmd_files = FileList["#{qmd_dir}/*.qmd"]
qmd_files.exclude('~*.qmd')
notebooks = qmd_files.pathmap('%{qmd,notebook}p').ext('.ipynb')
qmd_files.zip(notebooks).each do |qmd, notebook|
file notebook => notebook_dir
file notebook => qmd do
sh "quarto convert #{qmd} -o #{notebook}"
end
end
desc 'Convert qmd to ipynb files'
task convert: notebooks
file notebooks => notebook_dir
desc 'test to execute notebooks'
task test: notebooks do
notebooks.each do |notebook|
quarto_options = '--execute-daemon-restart --execute'
sh "bundle exec quarto render #{notebook} #{quarto_options}"
end
end
desc 'Start jupyter lab'
task jupyter: :convert do
jupyter_options =
"--notebook-dir='doc/notebook' --NotebookApp.token=''"
sh "bundle exec jupyter lab #{jupyter_options}"
end
CLEAN << 'doc/notebook'