From 79c7a57807289cdffc30132012f37b59fed54945 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 27 Dec 2018 01:17:14 -0500 Subject: tools/shman.sh: Generate "OPTIONS" sections --- (limited to 'tools') diff --git a/tools/shman.sh b/tools/shman.sh index ea4ff7f..5cf9aab 100644 --- a/tools/shman.sh +++ b/tools/shman.sh @@ -76,6 +76,11 @@ gen_doc_func() local args= local sect_name= local sect_desc= + local opt= + local optarg= + local desc= + local first_opt=true + local sect_opts= local sect_ret= sect_name=".SH NAME${LF}${sym}" @@ -87,6 +92,22 @@ gen_doc_func() 'details') sect_desc=".SH DESCRIPTION${LF}${args}" ;; + 'option') + read opt optarg desc <<-EOF + ${args} + EOF + if ${first_opt}; then + sect_opts=".SH OPTIONS${LF}" + fi + first_opt=false + if [ "x${optarg}" = 'x-' ]; then + opt=".B ${opt}" + else + opt=".BI ${opt} \\ ${optarg}" + fi + sect_opts="${sect_opts}.TP${LF}${opt}${LF}" + sect_opts="${sect_opts}${desc}${LF}" + ;; 'return') sect_ret=".SH RETURN VALUE${LF}${args}" ;; @@ -95,7 +116,7 @@ gen_doc_func() ${doc} EOF - printf '%s\n\n' "${sect_name}" "${sect_desc}" "${sect_ret}" + printf '%s\n\n' "${sect_name}" "${sect_desc}" "${sect_opts}" "${sect_ret}" } gen_doc() -- cgit v0.9.1