Fix usage of sed and man page on OSX

This commit is contained in:
Marc Di Luzio 2014-12-31 13:50:15 +00:00
parent 9c68372f64
commit 3f76b6430b
3 changed files with 31 additions and 19 deletions

View file

@ -30,7 +30,15 @@ add_custom_target(
)
# Install the ttrts man page
install( FILES "${CMAKE_BINARY_DIR}/ttrts.6" DESTINATION man/man6/ )
if( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
set ( MANPAGE_LOC share/man/man6 )
elseif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
set ( MANPAGE_LOC man/man6 )
else()
message(ERROR "Unsupported system detected")
endif()
install( FILES "${CMAKE_BINARY_DIR}/ttrts.6" DESTINATION ${MANPAGE_LOC} )
# Subprojects
add_subdirectory( source/ttrts )

View file

@ -1,13 +1,15 @@
#! /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
# 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
@ -19,13 +21,15 @@ echo ".TH TTRTS\ v$1.$2.$3 6 $(date +%Y-%m-%d) http://mdiluz.github.io/ttrts/" >
# underline mapfile opt
# ensure name section uses correct
cat "$5" \
| sed -r 's/^# (\w+)/.SH \1/g' \
| sed -r 's/^##+ (\w+)/.SS \1/g' \
| sed -r 's/^ (.*)$/\n\t\1\n/g' \
| sed -r 's/^\t//g' \
| sed -r 's/\$\{(\w+)\}/\\fB\$\1\\fR/g' \
| sed -r 's/\{(\w+)\}/\\fI\1\\fR/g' \
| sed -r 's/-----+//g' \
| sed -r 's/`(.*?)`/\\fB\1\\fR/g' \
| sed -r 's/MAPFILE/\\fImapfile\\fR/g' \
| sed -r 's/\tttrts -/\tttrts \\-/g' >> $4
| 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

View file

@ -1,10 +1,10 @@
#! /bin/bash
# Used to generate usage text from markdown
cat README.md \
| sed 's/^#\+ //g' \
| sed 's/^\t/\\t/g' \
| sed 's/^ /\\t/g' \
| sed ':a;N;$!ba;s/\n/\\n\n/g' \
| sed 's/^/\"/' \
| sed 's/$/\"/' \
| sed -E 's/^#+ //g' \
| sed -E 's/^ /\\t/g' \
| sed -E 's/^ /\\t/g' \
| sed -E 's/^/\"/' \
| sed -E 's/$/\\n\"/' \
> $1