2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-30 16:42:07 +00:00
rules_foreign_cc/docs/gen_header.sh
UebelAndre 8b8f31dd1b
Created a ./docs directory to house documentation (#466)
* Added links to docs to top level README

* Updated more docs

* Added generated header
2021-01-24 15:23:19 -08:00

32 lines
540 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
# The block below functions as follows
#
# - Look for all assignments
# - Remove all load statements
# - Remove multi line load statements
# - Remvoe all whitespace
# - Remove all comments
# - Strip assignments
# - Generate `- [symbol](#sybol)` formatting
# - Sort entries
TABLE_OF_CONTENTS=$(grep "=" "$1" \
| sed '/^load.*/d' \
| sed '/,$/d' \
| sed '/^$/d' \
| sed '/^#/d' \
| sed 's/ = .*//' \
| sed 's/\(.*\)/- [\1](#\1)/' \
| sort -f
)
cat << EOF > "$2"
# Rules Foreign CC
${TABLE_OF_CONTENTS}
EOF