arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / util_readme / util_readme.sh
blob986c393ca8d13b9d77a9b05af4c77ea347a59a97
1 #!/usr/bin/env bash
3 # Creates `./util/README.md` and `./Documentation/Util.md` of description files
4 # in `./util` subdirectories
6 # Execute from root of project. Example:
7 # `util/util_readme/util_readme.sh`
9 UTIL_README_DIR="$(cd "$(dirname "$0")" || exit; pwd -P)"
10 UTIL_DIR=$(dirname "$UTIL_README_DIR")
11 COREBOOT_ROOT_DIR=$(dirname "$UTIL_DIR")
12 DOCMENTATION_DIR="$COREBOOT_ROOT_DIR/Documentation"
13 SUMMARY='
14 ## List of utils
16 _Scripts and programs found in the coreboot `./util` directory_
18 APPEND_TO_UTIL_MD="${UTIL_README_DIR}/post_util.md"
20 DESCRIPTION_FILES=$(find "$UTIL_DIR" -name "description.md" | sort)
22 echo -n "" > "$UTIL_DIR/README.md"
24 echo
25 echo "[//]: # ( DO NOT EDIT - AUTOGENERATED FILE )";
26 echo
27 echo "[//]: # ( RUN 'util/util_readme/util_readme.sh' to regenerate )";
28 echo;
29 echo "# Utilities";
30 echo "${SUMMARY}"
31 } > "${DOCMENTATION_DIR}/util.md"
33 for DESC_FILE in $DESCRIPTION_FILES; do
34 UTIL_NAME=$(echo "$DESC_FILE" | rev | cut -d '/' -f2 | rev)
35 DESC=$(cat "$DESC_FILE")
37 if [[ $DESC == "__"${UTIL_NAME}* || $DESC == "__["${UTIL_NAME}* ]]; then
38 DESC="* $DESC"
39 else
40 DESC="* __${UTIL_NAME}__ - $DESC"
43 # format description to under 72 characters per line and only
44 # breaking on whitespace
45 DESC=$(echo "$DESC" \
46 | tr '\r\n' ' ' \
47 | sed 's/ [*]\+/\n\t\*/g' \
48 | sed 's/ \+/ /g' \
49 | fold -s -w72 \
50 | sed 's/\s*$//')
52 echo "$DESC" >> "$UTIL_DIR/README.md"
53 echo "$DESC" >> "$DOCMENTATION_DIR/util.md"
54 done
56 cat "${APPEND_TO_UTIL_MD}" >> "${DOCMENTATION_DIR}/util.md"