maint: fix documentation linting script and add to CI

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2024-10-26 18:22:17 +02:00
parent 319507c595
commit 73ef95df41
2 changed files with 21 additions and 39 deletions

View File

@ -15,12 +15,16 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
dnf install -y autoconf automake gcc gettext-devel libtool make pkgconfig dnf install -y autoconf automake gcc gettext-devel groff libtool make pkgconfig
dnf install -y aspell-devel check-devel gpm-devel libX11-devel "pkgconfig(ext2fs)" "pkgconfig(glib-2.0)" "pkgconfig(gmodule-2.0)" "pkgconfig(libssh2)" "pkgconfig(slang)" dnf install -y aspell-devel check-devel gpm-devel libX11-devel "pkgconfig(ext2fs)" "pkgconfig(glib-2.0)" "pkgconfig(gmodule-2.0)" "pkgconfig(libssh2)" "pkgconfig(slang)"
# For tests # For tests
dnf install -y glibc-gconv-extra util-linux dnf install -y glibc-gconv-extra util-linux
- name: Lint documentation
working-directory: maint
run: ./doctest
- name: Bootstrap build system - name: Bootstrap build system
run: ./autogen.sh run: ./autogen.sh

View File

@ -25,52 +25,30 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
#set -e set +e
MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(pwd)))} MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname "$(pwd)")}
#*** include section (source functions, for example) *******************
#*** file scope functions **********************************************
one_test() {
"$@" >/dev/null 2>doctest.err
if test -s doctest.err; then
echo "ERROR messages follow:" 2>&1
cat doctest.err 2>&1
echo "ERROR while running following command:" 2>&1
echo "$@" 2>&1
echo "ERROR messages are preserved in doctest.err"
exit 1
fi
}
#*** main code ********************************************************* #*** main code *********************************************************
[ -r "${MC_SOURCE_ROOT_DIR}/doc/man/mc.1.in" ] || { [ -r "${MC_SOURCE_ROOT_DIR}/doc/man/mc.1.in" ] || {
echo "ERROR: cannot read doc/mc.1.in" 2>&1 echo "ERROR: cannot read doc/man/mc.1.in" 2>&1
exit 1 exit 1
} }
# Test the documentation for possible errors. for cmd in groff nroff ; do
for i in $(find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in'); do IFS='' ROFF_WARNINGS="$ROFF_WARNINGS
echo "test (groff): $i" $(
find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in' \
preconv -e UTF8 "${i}" | \ -exec sh -c "$cmd -K UTF-8 -Tutf8 -mandoc -ww '{}' | grep 'warning:'" \; 2>&1
groff -wall -mandoc -Tutf8 | \ )"
grep "warning:"
done done
for i in $(find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in'); do # Check that English manuals are in ASCII
echo "test (nroff): $i" ASCII_WARNINGS=$(find "${MC_SOURCE_ROOT_DIR}/doc" -maxdepth 1 -name '*.[1-9].in' -exec groff -Tascii -ww {} \; 2>&1)
preconv -e UTF8 "${i}" | \ if [ "x`printf '%s' "${ROFF_WARNINGS}${ASCII_WARNINGS}" | tr -d "$IFS"`" != x ] ; then
nroff -Tutf8 -mandoc | \ echo "$ROFF_WARNINGS" | sort -u | grep .
grep "warning:" echo "$ASCII_WARNINGS" | sort -u | grep .
done exit 1
fi
# Check the English manuals to be in ASCII.
one_test find "${MC_SOURCE_ROOT_DIR}/doc" -maxdepth 1 -name '*.[1-9].in' -exec groff -wall -Tascii {} \;
rm -rf doctest.err
exit 0