4 # This bash script generates CMSIS documentation
7 # - bash shell (for Windows: install git for Windows)
10 # - linkchecker (can be skipped with -s)
14 # Set version of gen pack library
15 # For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags.
16 # Use the tag name without the prefix "v", e.g., 0.7.0
17 REQUIRED_GEN_PACK_LIB="0.11.1"
19 DIRNAME=$(dirname "$(readlink -f "$0")")
21 REQ_DXY_VERSION="1.9.6"
22 REQ_MSCGEN_VERSION="0.20"
28 echo "Usage: $(basename "$0") [-h] [-s] [-c <comp>]"
29 echo " -h,--help Show usage"
30 echo " -s,--no-linkcheck Skip linkcheck"
31 echo " -c,--component <comp> Select component <comp> to generate documentation for. "
32 echo " Can be given multiple times. Defaults to all components."
35 while [[ $# -gt 0 ]]; do
41 '-s'|'--no-linkcheck')
49 echo "Invalid command line argument: $1" >&2
57 ############ DO NOT EDIT BELOW ###########
59 # Set GEN_PACK_LIB_PATH to use a specific gen-pack library root
60 # ... instead of bootstrap based on REQUIRED_GEN_PACK_LIB
61 if [[ -f "${GEN_PACK_LIB_PATH}/gen-pack" ]]; then
62 . "${GEN_PACK_LIB_PATH}/gen-pack"
64 . <(curl -sL "https://raw.githubusercontent.com/Open-CMSIS-Pack/gen-pack/main/bootstrap")
68 find_doxygen "${REQ_DXY_VERSION}"
69 find_utility "mscgen" "-l | grep 'Mscgen version' | sed -r -e 's/Mscgen version ([^,]+),.*/\1/'" "${REQ_MSCGEN_VERSION}"
70 [[ ${RUN_LINKCHECKER} != 0 ]] && find_linkchecker
72 if [ -z "${VERSION_FULL}" ]; then
73 VERSION_FULL=$(git_describe "v")
76 pushd "${DIRNAME}" > /dev/null || exit 1
78 echo_log "Generating documentation ..."
81 if [[ ! (${#COMPONENTS[@]} == 0 || ${COMPONENTS[*]} =~ $1) ]]; then
85 pushd "$1" > /dev/null || exit 1
87 projectName=$(grep -E "PROJECT_NAME\s+=" "$1.dxy.in" | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
88 projectNumberFull="$2"
89 if [ -z "${projectNumberFull}" ]; then
90 projectNumberFull=$(grep -E "PROJECT_NUMBER\s+=" "$1.dxy.in" | sed -r -e 's/[^"]*"[^0-9]*(([0-9]+\.[0-9]+(\.[0-9]+)?(-.+)?)?)".*/\1/')
92 if [ -z "${projectNumberFull}" ]; then
93 projectNumberFull="$(git rev-parse --short HEAD)"
95 projectNumber="${projectNumberFull%+*}"
96 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
99 sed -e "s/{projectNumber}/${projectNumber}/" "$1.dxy.in" > "$1.dxy"
101 mkdir -p "${DIRNAME}/${GENDIR}/$1/"
102 # git_changelog -f html -p "v" > src/history.txt
104 echo_log "\"${UTILITY_DOXYGEN}\" \"$1.dxy\""
105 "${UTILITY_DOXYGEN}" "$1.dxy"
107 mkdir -p "${DIRNAME}/${GENDIR}/$1/search/"
108 cp -f "${DIRNAME}/style_template/search.css" "${DIRNAME}/${GENDIR}/$1/search/"
109 cp -f "${DIRNAME}/style_template/navtree.js" "${DIRNAME}/${GENDIR}/$1/"
110 cp -f "${DIRNAME}/style_template/resize.js" "${DIRNAME}/${GENDIR}/$1/"
112 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/style_template/footer.js.in" \
113 | sed -e "s/{year}/${year}/" \
114 | sed -e "s/{projectName}/${projectName}/" \
115 | sed -e "s/{projectNumber}/${projectNumber}/" \
116 | sed -e "s/{projectNumberFull}/${projectNumberFull}/" \
117 > "${DIRNAME}/${GENDIR}/$1/footer.js"
119 popd > /dev/null || exit 1
122 generate "General" "${VERSION_FULL}"
136 cp -f "${DIRNAME}/index.html" "${DIRNAME}/../html/"
138 [[ ${RUN_LINKCHECKER} != 0 ]] && check_links --timeout 120 "${DIRNAME}/../html/index.html" "${DIRNAME}"
140 popd > /dev/null || exit 1