-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathgen_doc.sh
More file actions
executable file
·127 lines (107 loc) · 3.63 KB
/
gen_doc.sh
File metadata and controls
executable file
·127 lines (107 loc) · 3.63 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
# Version: 2.1
# Date: 2023-04-19
# This bash script generates AVH Documentation:
#
# Pre-requisites:
# - bash shell (for Windows: install git for Windows)
# - doxygen 1.13.2
# - graphviz (dot)
# - plantuml
set -o pipefail
# Set version of gen pack library
REQUIRED_GEN_PACK_LIB="0.13.0"
DIRNAME=$(dirname $(readlink -f $0))
DOXYGEN=$(which doxygen 2>/dev/null)
REQ_DXY_VERSION="1.13.2"
############ DO NOT EDIT BELOW ###########
function install_lib() {
local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
echo "Downloading gen-pack lib to '$2'"
mkdir -p "$2"
curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
}
function load_lib() {
if [[ -d ${GEN_PACK_LIB} ]]; then
. "${GEN_PACK_LIB}/gen-pack"
return 0
fi
local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
echo "Required gen-pack lib not found!" >&2
install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
fi
if [[ -d "${GLOBAL_LIB}" ]]; then
. "${GLOBAL_LIB}/gen-pack"
elif [[ -d "${USER_LIB}" ]]; then
. "${USER_LIB}/gen-pack"
else
echo "Required gen-pack lib is not installed!" >&2
exit 1
fi
}
load_lib
find_doxygen "${REQ_DXY_VERSION}"
GVDOT="$(find_utility dot)"
report_utility "dot" "$GVDOT" $?
PLANTUML="$(find_utility plantuml)"
if [[ -z "$PLANTUML" ]]; then
PLANTUML="$(type -p plantuml.bat)"
fi
report_utility "plantuml" "$PLANTUML" $?
###############################################
REGEN=0
ALLPARTS=($(find ${DIRNAME} -mindepth 1 -maxdepth 1 -type d -exec basename {} \;))
PARTS=()
if [[ -z "$*" ]]; then
REGEN=1
else
for part in "$*"; do
if [[ " ${ALLPARTS[@]} " =~ " $part " ]]; then
PARTS+=($part)
fi
done
fi
function doxygen {
partname=$(basename $(dirname $1))
if [[ $REGEN != 0 ]] || [[ " ${PARTS[@]} " =~ " ${partname} " ]]; then
pushd "$(dirname $1)" > /dev/null
echo "${UTILITY_DOXYGEN} $1"
"${UTILITY_DOXYGEN}" $(basename "$1")
popd > /dev/null
if [[ $2 != 0 ]]; then
# mkdir -p "${DIRNAME}/../Documentation/${partname}/html/search/"
cp -f "${DIRNAME}/Doxygen_Templates/navtree.js" "${DIRNAME}/../Documentation/${partname}/html/"
fi
projectName=$(grep -E "PROJECT_NAME\s+=" $1 | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
projectNumber=$(grep -E "PROJECT_NUMBER\s+=" $1 | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/Doxygen_Templates/footer.js" \
| sed -e "s/{projectName}/${projectName}/" \
| sed -e "s/{projectNumber}/${projectNumber}/" \
> "${DIRNAME}/../Documentation/${partname}/html/footer.js"
fi
}
function plantuml {
partname=$(basename $1)
if [[ $REGEN != 0 ]] || [[ " ${PARTS[@]} " =~ " ${partname} " ]]; then
pushd "$1" > /dev/null
echo "${PLANTUML} $1/src/*.uml"
"${PLANTUML}" ./src/*.uml
mkdir -p $1/src/images/
cp -f $1/src/*.png $1/src/images/
popd > /dev/null
fi
}
if [[ $REGEN != 0 ]]; then
echo "Cleaning existing documentation ..."
find "${DIRNAME}/../Documentation/" -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +
fi
echo "Generating documentation ..."
doxygen "${DIRNAME}/examples/examples.dxy" 1
doxygen "${DIRNAME}/infrastructure/infrastructure.dxy" 1
doxygen "${DIRNAME}/overview/overview.dxy" 1
plantuml "${DIRNAME}/simulation"
doxygen "${DIRNAME}/simulation/simulation.dxy" 1
exit 0