Skip to content

Commit 9aa694c

Browse files
committed
Better comment conversion script
1 parent c1b8e95 commit 9aa694c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

convert_all_jupyterlite.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
#!/bin/bash
22

3+
# This is a script which copies the contents of the tutorials
4+
# directory into a build directory (_build/ipynbs).
5+
# The notebook markdown files are converted to ipynbs with other
6+
# files (non-executable md files, static images, etc) are copied
7+
# directly.
8+
# This is intended for jupyterlite to build pointing to the build
9+
# directory since the markdown files do not currently work in
10+
# jupyterlite.
11+
312
# Find Markdown files convert.
4-
all_markdown_files=$(find tutorials -type f)
5-
if [ $# -gt 0 ]; then
6-
files_to_process="$@"
7-
else
8-
files_to_process=$all_markdown_files
9-
fi
13+
files_to_process=$(find tutorials -type f)
1014

1115
OUTDIR="_build/ipynbs"
1216

1317
# Identify Markdown files that are Jupytext and convert them all.
1418
for file in ${files_to_process}; do
19+
# Ensure result directory exists
1520
echo "Making directory: $OUTDIR/$(dirname $file)"
1621
mkdir -p $OUTDIR/$(dirname $file)
1722

1823
echo loop in $file
1924
# Extract the kernel information from the Jupytext Markdown file.
2025
kernel_info=$(grep -A 10 '^---$' "$file" | grep -E 'kernelspec')
21-
# Skip if no kernel information was found.
26+
# Copy directly if not a notebook file
2227
if [ -z "$kernel_info" ]; then
2328
cp $file $OUTDIR/$file
2429
continue
2530
fi
2631
# Convert to ipynb format, to be consumed by pytest nbval plugin.
2732
notebook_file="${file%.md}.ipynb"
2833
jupytext --to ipynb "$file" --output $OUTDIR/${notebook_file}
29-
# Stash file in array to be cleaned up at the end.
3034
done

0 commit comments

Comments
 (0)