Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tensorflow
GitHub Repository: tensorflow/docs-l10n
Path: blob/master/tools/ci/ja/bin/proofreading.sh
25118 views
1
#!/bin/sh
2
3
# Get target directory or file.
4
TARGET=${1}
5
6
# Other constants.
7
ERROR_LIMIT=20
8
RESULT_FORMAT="plain2"
9
10
# Find target files.
11
TARGET_FILES=$(find ${TARGET} -type f -name *.ipynb -or -name '*.md')
12
13
# Temporary directory. Convert notebooks to markdown and save them here.
14
TEMP_DIR=$(mktemp -d)
15
16
# Show configurations.
17
echo "TARGET: ${TARGET}"
18
echo "TEMP_DIR: ${TEMP_DIR}"
19
echo "ERROR_LIMIT: ${ERROR_LIMIT}"
20
echo ""
21
22
# Apply RedPen to target files.
23
for FILE in ${TARGET_FILES}; do
24
25
if [ ${FILE##*.} = "md" ]; then
26
TARGET_MARKDOWN=${FILE}
27
elif [ ${FILE##*.} = "ipynb" ]; then
28
# Convert ipynb to md and save it in temporary directory.
29
jupyter nbconvert --to markdown --output-dir ${TEMP_DIR} ${FILE}
30
TARGET_MARKDOWN="${TEMP_DIR}/$(basename ${FILE} .ipynb).md"
31
fi
32
33
redpen --result-format ${RESULT_FORMAT} \
34
--limit ${ERROR_LIMIT} \
35
--conf tools/ci/ja/redpen-conf.xml ${TARGET_MARKDOWN} \
36
2>tools/ci/ja/redpen.log
37
38
done
39
40