]> begriffs open source - cmsis-freertos/blob - Documentation/Doxygen/gen_doc.sh
Correct memory allocation and access in osMemoryPoolNew (#142)
[cmsis-freertos] / Documentation / Doxygen / gen_doc.sh
1 #!/usr/bin/env bash
2 # Version: 3.0
3 # Date: 2023-11-06
4 # This bash script generates CMSIS-FreeRTOS documentation
5 #
6 # Pre-requisites:
7 # - bash shell (for Windows: install git for Windows)
8 # - doxygen 1.13.2
9 # - linkchecker (can be skipped with -s)
10
11 set -o pipefail
12
13 # Set version of gen pack library
14 # For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags.
15 # Use the tag name without the prefix "v", e.g., 0.7.0
16 REQUIRED_GEN_PACK_LIB="0.11.0"
17
18 DIRNAME=$(dirname "$(readlink -f "$0")")
19 GENDIR=../html
20 REQ_DXY_VERSION="1.13.2"
21
22 RUN_LINKCHECKER=1
23 COMPONENTS=()
24
25 function usage() {
26   echo "Usage: $(basename "$0") [-h] [-s] [-c <comp>]"
27   echo " -h,--help               Show usage"
28   echo " -s,--no-linkcheck       Skip linkcheck"
29   echo " -c,--component <comp>   Select component <comp> to generate documentation for. "
30   echo "                         Can be given multiple times. Defaults to all components."
31 }
32
33 while [[ $# -gt 0 ]]; do
34   case $1 in
35     '-h'|'help')
36       usage
37       exit 1
38     ;;
39     '-s'|'--no-linkcheck')
40       RUN_LINKCHECKER=0
41     ;;
42     '-c'|'--component')
43       shift
44       COMPONENTS+=("$1")
45     ;;
46     *)
47       echo "Invalid command line argument: $1" >&2
48       usage
49       exit 1
50     ;;
51   esac
52   shift # past argument
53 done
54
55 ############ DO NOT EDIT BELOW ###########
56
57 # Set GEN_PACK_LIB_PATH to use a specific gen-pack library root
58 # ... instead of bootstrap based on REQUIRED_GEN_PACK_LIB
59 if [[ -f "${GEN_PACK_LIB_PATH}/gen-pack" ]]; then
60   . "${GEN_PACK_LIB_PATH}/gen-pack"
61 else
62   . <(curl -sL "https://raw.githubusercontent.com/Open-CMSIS-Pack/gen-pack/main/bootstrap")
63 fi
64
65 find_git
66 find_doxygen "${REQ_DXY_VERSION}"
67 [[ ${RUN_LINKCHECKER} != 0 ]] && find_linkchecker
68
69 if [ -z "${VERSION_FULL}" ]; then
70   VERSION_FULL=$(git_describe "v")
71 fi
72
73 pushd "${DIRNAME}" > /dev/null
74
75 echo_log "Generating documentation ..."
76
77 projectName=$(grep -E "PROJECT_NAME\s+=" freertos.dxy.in | sed -r -e 's/^PROJECT_NAME\s*=\s*"?([^"]*)"?/\1/')
78 projectNumberFull="${VERSION_FULL}"
79 projectNumber="${projectNumberFull%+*}"
80 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
81 year=$(date -u +'%Y')
82
83 sed -e "s/{projectNumber}/${projectNumber}/" freertos.dxy.in > freertos.dxy
84
85 git_changelog -f html -p "v" > src/history.txt
86
87 echo_log "\"${UTILITY_DOXYGEN}\" freertos.dxy"
88 "${UTILITY_DOXYGEN}" freertos.dxy
89
90 mkdir -p "${DIRNAME}/${GENDIR}/search/"
91 cp -f "${DIRNAME}/style_template/search.css" "${DIRNAME}/${GENDIR}/search/"
92 cp -f "${DIRNAME}/style_template/search.js" "${DIRNAME}/${GENDIR}/search/"
93 cp -f "${DIRNAME}/style_template/navtree.js" "${DIRNAME}/${GENDIR}"
94 cp -f "${DIRNAME}/style_template/resize.js" "${DIRNAME}/${GENDIR}"
95
96 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/style_template/footer.js.in" \
97   | sed -e "s/{year}/${year}/" \
98   | sed -e "s/{projectName}/${projectName}/" \
99   | sed -e "s/{projectNumber}/${projectNumber}/" \
100   | sed -e "s/{projectNumberFull}/${projectNumberFull}/" \
101   > "${DIRNAME}/${GENDIR}/footer.js"
102
103 popd > /dev/null || exit 1
104
105 [[ ${RUN_LINKCHECKER} != 0 ]] && check_links "${DIRNAME}/${GENDIR}/index.html" "${DIRNAME}"
106
107 exit 0