Debian Codegraph @

util/util_readme/util_readme.sh

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