Merge branch '3698_etags_codejump'
[midnight-commander.git] / maint / utils / doctest
blob5ed5311e0c9a7cb000d4dbf4e6e07c74a4d4ff6a
1 #!/bin/bash
3 # Midnight Commander - check the documentation for compatibility with groff and nroff.
5 # Copyright (C) 2002, 2003, 2011, 2013
6 # The Free Software Foundation, Inc.
8 # Written by:
9 # Pavel Roskin <proski@gnu.org> 2002, 2003
10 # Ilia Maslakov <il.smind@gmail.com>, 2011
11 # Slava Zanko <slavazanko@gmail.com>, 2013
13 # This file is part of the Midnight Commander.
15 # The Midnight Commander is free software: you can redistribute it
16 # and/or modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation, either version 3 of the License,
18 # or (at your option) any later version.
20 # The Midnight Commander is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #set -e
30 MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(pwd)))}
32 #*** include section (source functions, for example) *******************
34 #*** file scope functions **********************************************
36 one_test() {
37 "$@" >/dev/null 2>doctest.err
38 if test -s doctest.err; then
39 echo "ERROR messages follow:" 2>&1
40 cat doctest.err 2>&1
41 echo "ERROR while running following command:" 2>&1
42 echo "$@" 2>&1
43 echo "ERROR messages are preserved in doctest.err"
44 exit 1
48 #*** main code *********************************************************
50 [ -r "${MC_SOURCE_ROOT_DIR}/doc/man/mc.1.in" ] || {
51 echo "ERROR: cannot read doc/mc.1.in" 2>&1
52 exit 1
55 # Test the documentation for possible errors.
56 for i in $(find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in'); do
57 echo "test (groff): $i"
59 preconv -e UTF8 "${i}" | \
60 groff -wall -mandoc -Tutf8 | \
61 grep "warning:"
62 done
64 for i in $(find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in'); do
65 echo "test (nroff): $i"
67 preconv -e UTF8 "${i}" | \
68 nroff -Tutf8 -mandoc | \
69 grep "warning:"
70 done
72 # Check the English manuals to be in ASCII.
73 one_test find "${MC_SOURCE_ROOT_DIR}/doc" -maxdepth 1 -name '*.[1-9].in' -exec groff -wall -Tascii {} \;
75 rm -rf doctest.err
76 exit 0