2016-03-03 08:18:52 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# get into this script's directory
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
[ "$1" = '-q' ] || {
|
|
|
|
set -x
|
|
|
|
pwd
|
|
|
|
}
|
|
|
|
|
2020-02-13 02:23:58 +08:00
|
|
|
if ! type go-md2man; then
|
2018-02-02 20:51:57 +08:00
|
|
|
echo "To install man pages, please install 'go-md2man'."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-03-03 08:18:52 +08:00
|
|
|
for FILE in *.md; do
|
|
|
|
base="$(basename "$FILE")"
|
|
|
|
name="${base%.md}"
|
|
|
|
num="${name##*.}"
|
|
|
|
if [ -z "$num" -o "$name" = "$num" ]; then
|
|
|
|
# skip files that aren't of the format xxxx.N.md (like README.md)
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
mkdir -p "./man${num}"
|
|
|
|
go-md2man -in "$FILE" -out "./man${num}/${name}"
|
|
|
|
done
|