Refine the Custom type of generated '*-modes' options
[emacs.git] / admin / check-man-pages
blob8f05b75d81ce5955a2a4f71c972b6885e2d415b0
1 #!/bin/bash
2 ### check-man-pages - check man pages for errors
4 ## Copyright (C) 2022-2024 Free Software Foundation, Inc.
6 ## Author: Stefan Kangas <stefankangas@gmail.com>
8 ## This file is part of GNU Emacs.
10 ## GNU Emacs is free software: you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
15 ## GNU Emacs is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
23 ### Commentary:
25 ## Check Emacs man pages for errors using `man'.
27 ### Code:
29 source "${0%/*}/emacs-shell-lib"
31 exit_status=0
33 cd "$PD"/../doc/man
34 for page in *.1; do
35 # ctags.1 just includes the man page etags.1, which AFAICT will
36 # default to the one installed on the system (!), instead of the
37 # one in the repository. So checking it is pointless, and we will
38 # in any case already check etags.1 separately.
39 if [ "$page" == "ctags.1" ]; then
40 continue
42 log=$(emacs_mktemp)
43 LC_ALL=C.UTF-8 MANROFFSEQ='' MANWIDTH=80 \
44 man --warnings=all,mac -E UTF-8 -l -Tutf8 -Z "$page" >/dev/null 2> "$log"
45 log_size=$(stat --format=%s "$log")
46 if [ "$log_size" -ne 0 ]; then
47 echo "doc/man/$page:"
48 # Point to the correct file for *compilation* buffers.
49 cat "$log" \
50 | sed 's/troff: man1\/\([^ ]\+\)\.1/troff: doc\/man\/\1.1/' \
51 | sed "s/<standard input>/doc\/man\/$page/"
52 exit_status=1
54 done
56 exit $exit_status