2018-03-09 05:42:45 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-05-10 09:46:34 +03:00
|
|
|
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2018-03-08 09:54:14 +02:00
|
|
|
# _VERBOSE_=1
|
|
|
|
# _TEST_=1
|
|
|
|
|
|
|
|
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
ROOT_DIR=$(realpath "$BASE_DIR/..")
|
|
|
|
SCRIPTS_DIR="$ROOT_DIR/scripts"
|
|
|
|
|
|
|
|
source "$SCRIPTS_DIR/common/echo.sh"
|
|
|
|
source "$SCRIPTS_DIR/common/mkdir.sh"
|
|
|
|
source "$SCRIPTS_DIR/common/detect.sh"
|
|
|
|
|
|
|
|
_detect "doxygen"
|
2018-03-08 11:30:47 +02:00
|
|
|
_detect "pdflatex" 1
|
2018-03-08 09:54:14 +02:00
|
|
|
|
|
|
|
source "$BASE_DIR/langs.sh"
|
|
|
|
DOXYFILE="api.doxyfile"
|
2018-03-26 08:50:13 +03:00
|
|
|
OUTPUT="$BASE_DIR/_output"
|
|
|
|
|
|
|
|
# \usepackage{CJKutf8}
|
|
|
|
# \begin{document}
|
|
|
|
# \begin{CJK}{UTF8}{gbsn}
|
|
|
|
# ...
|
|
|
|
# \end{CJK}
|
|
|
|
# \end{document}
|
|
|
|
_texcjk() {
|
|
|
|
tex="$1"; shift;
|
|
|
|
_echo_in "add cjk to $tex"
|
2018-07-08 08:04:41 +03:00
|
|
|
sed -i "" -E $'s/^\\\\begin{document}$/\\\\usepackage{CJKutf8}\\\n\\\\begin{document}\\\n\\\\begin{CJK}{UTF8}{gbsn}/g' $tex
|
|
|
|
sed -i "" -E $'s/^\\\\end{document}$/\\\\end{CJK}\\\n\\\\end{document}/g' $tex
|
2018-03-26 08:50:13 +03:00
|
|
|
}
|
2018-03-08 09:54:14 +02:00
|
|
|
|
|
|
|
for lang in "${LANGS[@]}"; do
|
|
|
|
_echo_s "Build doc $lang"
|
2018-03-08 11:30:47 +02:00
|
|
|
[ -d "$BASE_DIR/$lang" ] || continue
|
2018-03-08 09:54:14 +02:00
|
|
|
cd "$BASE_DIR/$lang"
|
|
|
|
if [ -f "$DOXYFILE" ]; then
|
|
|
|
_mkdir "$OUTPUT/$lang"
|
|
|
|
_echo_i "doxygen $DOXYFILE"
|
|
|
|
doxygen $DOXYFILE
|
2018-10-22 17:18:22 +03:00
|
|
|
|
|
|
|
version=`cat $DOXYFILE | grep -m1 "^PROJECT_NUMBER\s*=" | \
|
|
|
|
sed -E "s/^.*=[[:space:]]*(.*)[[:space:]]*$/\1/g"`
|
|
|
|
|
|
|
|
# html
|
|
|
|
if [ -d "$OUTPUT/$lang/html" ]; then
|
2018-11-08 16:51:21 +02:00
|
|
|
dirname="mynt-eye-s-sdk-apidoc"; \
|
2018-10-22 17:18:22 +03:00
|
|
|
[ -n "$version" ] && dirname="$dirname-$version"; \
|
|
|
|
dirname="$dirname-$lang"
|
|
|
|
cd "$OUTPUT/$lang"
|
|
|
|
[ -d "$dirname" ] && rm -rf "$dirname"
|
|
|
|
mv "html" "$dirname" && zip -r "$dirname.zip" "$dirname"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# latex
|
2018-03-08 11:30:47 +02:00
|
|
|
if [ $pdflatex_FOUND ] && [ -f "$OUTPUT/$lang/latex/Makefile" ]; then
|
2018-03-08 09:54:14 +02:00
|
|
|
_echo_in "doxygen make latex"
|
2018-11-08 16:51:21 +02:00
|
|
|
filename="mynt-eye-s-sdk-apidoc"; \
|
2018-07-08 08:04:41 +03:00
|
|
|
[ -n "$version" ] && filename="$filename-$version"; \
|
|
|
|
filename="$filename-$lang.pdf"
|
2018-03-26 08:50:13 +03:00
|
|
|
cd "$OUTPUT/$lang/latex" && _texcjk refman.tex && make
|
2018-07-08 08:04:41 +03:00
|
|
|
[ -f "refman.pdf" ] && mv "refman.pdf" "../$filename"
|
2018-03-08 09:54:14 +02:00
|
|
|
fi
|
2018-10-22 17:18:22 +03:00
|
|
|
|
2018-03-08 09:54:14 +02:00
|
|
|
_echo_d "doxygen completed"
|
|
|
|
else
|
|
|
|
_echo_e "$DOXYFILE not found"
|
|
|
|
fi
|
|
|
|
done
|