Martin Roth has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/48962 )
Change subject: util/util_readme: Make string formatting its own function ......................................................................
util/util_readme: Make string formatting its own function
In preparation for treating the output to the UTIL_DIR and the DOCUMENTATION_DIR differently, move the description formatting to its own function.
Signed-off-by: Martin Roth martin@coreboot.org Change-Id: If405083460bbc095a84c92845a3fddd951feec5c --- M util/util_readme/util_readme.sh 1 file changed, 14 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/48962/1
diff --git a/util/util_readme/util_readme.sh b/util/util_readme/util_readme.sh index af688c4..64b4232 100755 --- a/util/util_readme/util_readme.sh +++ b/util/util_readme/util_readme.sh @@ -12,6 +12,18 @@ DOCMENTATION_DIR="$COREBOOT_ROOT_DIR/Documentation" SUMMARY="_Scripts and programs found in the `./util` directory_"
+# format description to under 72 characters per line and only +# breaking on whitespace +fmtstring() { + echo "$1" \ + | tr '\r\n' ' ' \ + | sed 's/ [*]+/\n\t*/g' \ + | sed 's/ +/ /g' \ + | fold -s -w72 \ + | sed 's/\s*$//' + echo +} + DESCRIPTION_FILES=$(find "$UTIL_DIR" -name "description.md" | sort)
echo -n "" > "$UTIL_DIR/README.md" @@ -28,15 +40,6 @@ DESC="* __${UTIL_NAME}__ - $DESC" fi
- # format description to under 72 characters per line and only - # breaking on whitespace - DESC=$(echo "$DESC" \ - | tr '\r\n' ' ' \ - | sed 's/ [*]+/\n\t*/g' \ - | sed 's/ +/ /g' \ - | fold -s -w72 \ - | sed 's/\s*$//') - - echo "$DESC" >> "$UTIL_DIR/README.md" - echo "$DESC" >> "$DOCMENTATION_DIR/util.md" + fmtstring "$DESC" >> "$UTIL_DIR/README.md" + fmtstring "$DESC" >> "$DOCMENTATION_DIR/util.md" done