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"
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 "<!-- DO NOT EDIT - AUTOGENERATED FILE -->";
25 echo "<!-- RUN 'util/util_readme/util_readme.sh' to regenerate -->";
29 } > "${DOCMENTATION_DIR}/util.md"
31 for DESC_FILE
in $DESCRIPTION_FILES; do
32 UTIL_NAME
=$
(echo "$DESC_FILE" |
rev | cut
-d '/' -f2 |
rev)
33 DESC
=$
(cat "$DESC_FILE")
35 if [[ $DESC == "__"${UTIL_NAME}* ||
$DESC == "__["${UTIL_NAME}* ]]; then
38 DESC
="* __${UTIL_NAME}__ - $DESC"
41 # format description to under 72 characters per line and only
42 # breaking on whitespace
45 |
sed 's/ [*]\+/\n\t\*/g' \
50 echo "$DESC" >> "$UTIL_DIR/README.md"
51 echo "$DESC" >> "$DOCMENTATION_DIR/util.md"
54 cat "${APPEND_TO_UTIL_MD}" >> "${DOCMENTATION_DIR}/util.md"