aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-09-17 21:20:55 +0200
committerRobin Jarry <robin@jarry.cc>2023-09-19 22:57:32 +0200
commit78e17a0db3a9d113a6957482245926373dc50f9b (patch)
tree513a4ce6e65511303d47ddb972a06893f9edd991
parentde0b75d191f4f789d3870dae00871244d20aaf10 (diff)
downloadaerc-78e17a0db3a9d113a6957482245926373dc50f9b.tar.gz
aerc-78e17a0db3a9d113a6957482245926373dc50f9b.zip
contrib: add script to check man pages consistency
Add a new shell script to check that all commands are documented in man pages and that the man pages do not contain non-existent commands. Also check that all explicitly parsed options with ini reflection are documented as well. It is not possible to check if the man pages do reference non-existent options since some of the options are parsed lazily in workers and some of them are also declared with placeholders (e.g. *column-<name>*). Run the script in the lint target. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
-rw-r--r--GNUmakefile1
-rwxr-xr-xcontrib/check-docs59
2 files changed, 60 insertions, 0 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 7704fcdb..95556bcf 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -53,6 +53,7 @@ linters.so: contrib/linters.go
lint: linters.so
@contrib/check-whitespace `git ls-files ':!:filters/vectors'` && \
echo white space ok.
+ @contrib/check-docs && echo docs ok.
@$(GO) run mvdan.cc/gofumpt@$(gofumpt_tag) -d . | grep ^ \
&& echo The above files need to be formatted, please run make fmt && exit 1 \
|| echo all files formatted.
diff --git a/contrib/check-docs b/contrib/check-docs
new file mode 100755
index 00000000..b92ca3c0
--- /dev/null
+++ b/contrib/check-docs
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+tmp=$(mktemp)
+trap "rm -f $tmp" EXIT
+
+global_fail=0
+
+cmd_scd_sed='s/^\*:([a-z][a-z-]*)\*.*/\1/p'
+cmd_go_sed='/^func ([[:alnum:]]\+) Aliases() \[\]string {$/{n; s/", "/ /g; s/.*return \[\]string{"\(.*\)"}/\1/p}'
+
+fail=0
+sed -nre "$cmd_scd_sed" doc/*.scd > "$tmp"
+for f in $(find commands -type f -name '*.go'); do
+ for cmd in $(sed -ne "$cmd_go_sed" "$f"); do
+ if ! grep -qFx "$cmd" "$tmp"; then
+ grep -HnF --color "\"$cmd\"" "$f"
+ fail=$((fail+1))
+ fi
+ done
+done
+
+if [ "$fail" -gt 0 ]; then
+ echo "error: $fail command(s) not documented in man pages" >&2
+ global_fail=1
+fi
+
+fail=0
+sed -ne "$cmd_go_sed" $(find commands -type f -name '*.go') | tr ' ' '\n' > "$tmp"
+for f in doc/*.scd; do
+ for cmd in $(sed -nre "$cmd_scd_sed" "$f"); do
+ if ! grep -qFx "$cmd" "$tmp"; then
+ grep -Hn --color "^\\*:$cmd\\*" "$f"
+ fail=$((fail+1))
+ fi
+ done
+done
+
+if [ "$fail" -gt 0 ]; then
+ echo "error: $fail non-existent command(s) documented in man pages" >&2
+ global_fail=1
+fi
+
+fail=0
+sed -nre 's/^\*([a-z][a-z-]*)\* = .*/\1/p' doc/*.scd > "$tmp"
+for f in $(find config -type f -name '*.go'); do
+ for opt in $(sed -nre 's/.*`ini:"([a-z][a-z-]*)".*/\1/p' $f); do
+ if ! grep -qFx "$opt" "$tmp"; then
+ grep -HnF --color "\"$opt\"" "$f"
+ fail=$((fail+1))
+ fi
+ done
+done
+
+if [ "$fail" -gt 0 ]; then
+ echo "error: $fail option(s) not documented in man pages" >&2
+ global_fail=1
+fi
+
+exit $global_fail