From a37251289a7825e80b690cbd1719298889d9d773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 29 Jun 2021 23:59:34 +0200 Subject: [PATCH] Support **non-replaceable strings** in synopsis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- hack/man-page-checker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/man-page-checker b/hack/man-page-checker index 28dc73f5..dceb1b77 100755 --- a/hack/man-page-checker +++ b/hack/man-page-checker @@ -99,6 +99,9 @@ function compare_usage() { from_man=$(sed -E -e 's/^\[\*options\*\][[:space:]]*//' <<<"$from_man") from_help=$(sed -E -e 's/^\[command options\][[:space:]]*//' <<<"$from_help") + # Constant strings in man page are '**foo**', in --help are 'foo'. + from_man=$(sed -E -e 's/\*\*([^*]+)\*\*/\1/g' <<<"$from_man") + # Args in man page are '*foo*', in --help are 'FOO'. Convert all to # UPCASE simply because it stands out better to the eye. from_man=$(sed -E -e 's/_([a-z-]+)_/\U\1/g' <<<"$from_man") @@ -121,7 +124,7 @@ for md in *.1.md;do # arguments are bracketed by single ones. # E.g. '**skopeo copy** [*options*] _..._' # Get the command name, and confirm that it matches the md file name. - cmd=$(echo "$synopsis" | sed -E -e 's/(.*)\*\*.*/\1/' | tr -d \*) + cmd=$(echo "$synopsis" | sed -E -e 's/^\*\*([^*]+)\*\*.*/\1/' | tr -d \*) # Use sed, not tr, so we only replace the first dash: we want # skopeo-list-tags -> "skopeo list-tags", not "skopeo list tags" md_nodash=$(basename "$md" .1.md | sed -e 's/-/ /')