-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
run.sh
executable file
·45 lines (30 loc) · 860 Bytes
/
run.sh
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
#!/usr/bin/env bash
set -e
TOTAL_WORDS=0
WORDS_IN_PAGE=250
make_lesson() {
local script=$1
local outfile=$(basename $script .py)".md"
local tmpfile=$(basename $script .py)".tmp"
#echo '" Set text width as 72.' >${tmpfile}
#echo "" >>${tmpfile}
$script >${tmpfile}
python3 -m mdpyformat.tocgen ${tmpfile} ${outfile}
#rm ${tmpfile}
WORDS=$(wc -w "${outfile}" | awk '{ print $1 }')
echo "${WORDS} words in ${outfile}"
((TOTAL_WORDS+=WORDS))
}
cat <<EOF
Generating tutorial text:
EOF
make_lesson ./python-obj-system.py
make_lesson ./decorator.py
make_lesson ./gen-iterator.py
((NUM_PAGES=TOTAL_WORDS/WORDS_IN_PAGE))
cat <<EOF
===
Total number of words: ${TOTAL_WORDS}
This would make ${NUM_PAGES} pages, given an average number of ${WORDS_IN_PAGE} words per page.
*** all tutorials generated ***"
EOF