convert-markdown-into-ipynb-and-test.sh 835 字节
Newer Older
G
gongweibao 已提交
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
#!/bin/sh
command -v go >/dev/null 2>&1
if [ $? != 0 ]; then
    echo >&2 "Please install go https://golang.org/doc/install#install"
    exit 1
fi

GOPATH=/tmp/go go get -u github.com/wangkuiyi/ipynb/markdown-to-ipynb

cur_path=$(dirname $(readlink -f $0))
cd $cur_path/../

#convert md to ipynb
for file in */{README,README\.en}.md ; do
    /tmp/go/bin/markdown-to-ipynb < $file > ${file%.*}".ipynb"
    if [ $? != 0 ]; then
        echo >&2 "markdown-to-ipynb $file error"
        exit 1
    fi
done

if [[ ! -z $TEST_EMBEDDED_PYTHON_SCRIPTS ]]; then
    exit 0
fi

#exec ipynb's py file
for file in */{README,README\.en}.ipynb ; do
    pushd $PWD > /dev/null
    cd $(dirname $file) > /dev/null

    echo "begin test $file"
    jupyter nbconvert --to python $(basename $file) --stdout | python

    popd > /dev/null
    #break
done