Skip to content

Commit 4a98300

Browse files
nabijaczlewelibehlendorf
authored andcommitted
mancheck: accept lints, accept lint overrides
Reviewed-by: Richard Laager <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Nguyen <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12129
1 parent 7837845 commit 4a98300

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

Makefile.am

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,7 @@ storeabi: lib
137137

138138
PHONY += mancheck
139139
mancheck:
140-
@if type mandoc > /dev/null 2>&1; then \
141-
find ${top_srcdir}/man ${top_srcdir}/tests/test-runner/man -type f -name '*[1-9]*' \
142-
-exec mandoc -Tlint -Werror {} \+; \
143-
else \
144-
echo "skipping mancheck because mandoc is not installed"; \
145-
fi
140+
${top_srcdir}/scripts/mancheck.sh ${top_srcdir}/man ${top_srcdir}/tests/test-runner/man
146141

147142
if BUILD_LINUX
148143
stat_fmt = -c '%A %n'

scripts/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ EXTRA_SCRIPTS = \
1717
kmodtool \
1818
make_gitrev.sh \
1919
man-dates.sh \
20-
paxcheck.sh
20+
paxcheck.sh \
21+
mancheck.sh
2122

2223
EXTRA_DIST = \
2324
cstyle.pl \

scripts/mancheck.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
#
3+
# Permission to use, copy, modify, and/or distribute this software for
4+
# any purpose with or without fee is hereby granted.
5+
#
6+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
7+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
8+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
9+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
11+
# AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12+
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13+
#
14+
# shellcheck disable=SC2086
15+
16+
if [ "$#" -eq 0 ]; then
17+
echo "Usage: $0 manpage-directory..."
18+
exit 1
19+
fi
20+
21+
if ! command -v mandoc > /dev/null; then
22+
echo "skipping mancheck because mandoc is not installed"
23+
exit 0
24+
fi
25+
26+
IFS="
27+
"
28+
29+
files="$(find "$@" -type f -name '*[1-9]*' ! -name '*module-param*' ! -name 'zpool-features*' ! -name 'zfs-mount-generator*')" || exit 1
30+
31+
add_excl="$(awk '
32+
/^.\\" lint-ok:/ {
33+
print "-e"
34+
$1 = "mandoc:"
35+
$2 = FILENAME ":[[:digit:]]+:[[:digit:]]+:"
36+
print
37+
}' $files)"
38+
39+
# Redirect to file instead of 2>&1ing because mandoc flushes inconsistently(?) which tears lines
40+
# https://github.com/openzfs/zfs/pull/12129/checks?check_run_id=2701608671#step:5:3
41+
etmp="$(mktemp)"
42+
! { mandoc -Tlint $files 2>"$etmp"; cat "$etmp"; rm -f "$etmp"; } |
43+
grep -vE -e 'mandoc: outdated mandoc.db' -e 'STYLE: referenced manual not found' $add_excl >&2

0 commit comments

Comments
 (0)