ttrts/scripts/gen_manpage.sh

36 lines
1.3 KiB
Bash
Raw Normal View History

#! /bin/bash
# Used to a man page from markdown
echo ".\" Man page for the ttrts project" > $4
echo ".\" this man page is auto-generated, do not edit directly" >> $4
echo ".TH TTRTS\ v$1.$2.$3 6 $(date +%Y-%m-%d) http://mdiluz.github.io/ttrts/" >> $4
2014-12-31 13:50:15 +00:00
# NOTE: For the OSX version of sed we use -E, which on linux appears be an undocumented switch for -r
# we also have to use [A-Za-z] instead of \w for some reason
# as well as escaped new line characters and literal tabs instead of \n and \t
# sections to section headers
# sub-sections in man page sub-sections
# 4-space lines to tabs
# tab starts removed
# Environment variables in bold
# User variables in italics
# remove all line-widths
# Put all back-ticks quotes in bold
# underline mapfile opt
# ensure name section uses correct
cat "$5" \
2014-12-31 13:50:15 +00:00
| sed -E 's/^# ([A-Za-z]+)/.SH \1/g' \
| sed -E 's/^##+ ([A-Za-z]+)/.SS \1/g' \
| sed -E 's/^ (.*)$/\
\1\
/g' \
| sed -E 's/^ //g' \
| sed -E 's/\$\{([A-Za-z]+)\}/\\fB\$\1\\fR/g' \
| sed -E 's/\{([A-Za-z]+)\}/\\fI\1\\fR/g' \
| sed -E 's/-----+//g' \
| sed -E 's/`(.*)`/\\fB\1\\fR/g' \
| sed -E 's/MAPFILE/\\fImapfile\\fR/g' \
| sed -E 's/ ttrts -/ ttrts \\-/g' >> $4