diff options
author | merakor <cem@ckyln.com> | 2021-03-12 12:22:30 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-03-12 12:22:30 +0000 |
commit | 81e3f00288d6fdc93de2dc31c065ebe3bdb1adf5 (patch) | |
tree | c68eef3692212bb7dd6be17f44b8afbdf478b5a7 /tools | |
parent | f086f31f2e7c0418d888a2db5accf78ae0e5d8e0 (diff) | |
download | cpt-81e3f00288d6fdc93de2dc31c065ebe3bdb1adf5.tar.gz |
docs: update
FossilOrigin-Name: fb505a8b22eb533c8857eaa002228f2c950ac1cdb4c7b314daf7b61cb25bed53
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/tool2man.sh | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/tool2man.sh b/tools/tool2man.sh index 82e4807..9111243 100755 --- a/tools/tool2man.sh +++ b/tools/tool2man.sh @@ -5,6 +5,18 @@ # page format. The intention behind this utility is to generate manual pages for # contrib scripts without much hassle. +# Syntax: +# Every line starts with two hashes and a space ('## '). If the line ends with a +# colon (':'), it is assumed to be a section header. Subsections follow the same +# convention, but uses three hashes instead of two. An empty '## ' line will +# start a new paragraph (.Pp). Otherwise, mdoc(7) syntax is used as is. +# Headers are generated using the script's name, and the docstring is used from +# the line following the shebang. +# +# 'See also' section is pregenerated and only points the user to cpt(1). Others +# can be added with the following line and format: +# ## see: cpt-fork.1 this-manpage.5 + case "$1" in --help|-h|'') printf 'usage: %s [file]\n' "${0##*/}" >&2 @@ -15,8 +27,9 @@ out() { printf '%s\n' "$@"; } file=$1 filename=${file##*/} +see='' date=$(date "+%b %d, %Y") -docstr=$(sed -n '2s/# //p' $file) +docstr=$(sed -n '2s/# //p' "$file" | tr '[:upper:]' '[:lower:]') out \ ".Dd $date" \ @@ -31,6 +44,10 @@ while read -r line; do line=${line%:} out ".Ss ${line#'### '}" ;; + '## see':*) + line=${line##*:} + see=$line + ;; '##'*:) line=${line%:} out ".Sh ${line#'## '}" @@ -50,3 +67,13 @@ done < "$file" out ".Sh AUTHOR" ".An Cem Keylan Aq Mt cem@ckyln.com" out ".Sh LICENSE" "See LICENSE for copyright information." out ".Sh SEE ALSO" ".Xr cpt 1" +[ "$see" ] && + for man in $see; do + out ".Xr ${man%.[0-9]} ${man##*.}" + done +out ".Pp" +out "The full documentation of cpt is available as an info page." +out "If either" ".Ic info" or ".Ic texinfo" +out "package is installed on your system, you can run" +out ".Bd -literal -offset indent" "info cpt" ".Ed" +out .Pp "to learn more about the package manager." |