Files
chasquid/docs/man/generate.sh
Alberto Bertogli a80051657a docs/man: Auto-generate markdown manpages
This patch adds auto-generation of markdown manpages, for ease of
reference in other documents and links.
2023-10-04 00:31:14 +01:00

31 lines
694 B
Bash
Executable File

#!/bin/bash
#
# Convert pod files to manual pages, using pod2man.
#
# Assumes files are named like:
# <name>.<section>.pod
set -e
for IN in *.pod; do
OUT=$(basename "$IN" .pod)
SECTION=${OUT##*.}
NAME=${OUT%.*}
# If it has not changed in git, set the mtime to the last commit that
# touched the file.
CHANGED=$( git status --porcelain -- "$IN" | wc -l )
if [ "$CHANGED" -eq 0 ]; then
GIT_MTIME=$( git log --pretty=%at -n1 -- "$IN" )
touch -d "@$GIT_MTIME" "$IN"
fi
podchecker "$IN"
pod2man --section="$SECTION" --name="$NAME" \
--release "" --center "" \
"$IN" "$OUT"
pod2markdown "$IN" \
| sed 's@\([a-z.-]\+\)(\([1-9]\))@[\1(\2)](\1.\2.md)@g' \
> "$OUT.md"
done