Change man(1) to use mandoc to render manpages

man(1) now first test the manpage to run with mandoc to make sure it can be
rendered.
In case groff cannot be found (because base has been built WITHOUT_GROFF) it
recommands to install groff from the packages
This commit is contained in:
Baptiste Daroussin 2014-11-23 00:08:04 +00:00
parent b9cfeb20f6
commit d6096801f1

View File

@ -276,11 +276,8 @@ man_check_for_so() {
return 0
}
# Usage: man_display_page
# Display either the manpage or catpage depending on the use_cat variable
man_display_page() {
local EQN NROFF PIC TBL TROFF REFER VGRIND
local IFS l nroff_dev pipeline preproc_arg tool
local IFS pipeline preconv_enc testline
# We are called with IFS set to colon. This causes really weird
# things to happen for the variables that have spaces in them.
@ -312,6 +309,49 @@ man_display_page() {
return
fi
case "${manpage}" in
*.${man_charset}/*)
case "$man_charset" in
ISO8859-1) preconv_enc="latin-1" ;;
ISO8859-15) preconv_enc="latin-1" ;;
UTF-8) preconv_enc="utf-8" ;;
esac
;;
esac
if [ -n "$preconv_enc" ]; then
pipeline="preconv -e $preconv_enc |"
fi
testline="$pipeline mandoc -Tlint -Werror 2>/dev/null"
pipeline="$pipeline mandoc -Tlocale | $MANPAGER"
if ! eval "$cattool $manpage | $testline" ;then
if which -s groff2; then
man_display_page_groff
else
echo "This manpage needs groff(1) to be rendered" >&2
echo "First install groff(1): " >&2
echo "pkg install groff " >&2
ret=1
fi
return
fi
if [ $debug -gt 0 ]; then
decho "Command: $cattool $manpage | $pipeline"
ret=0
else
eval "$cattool $manpage | $pipeline"
ret=$?
fi
}
# Usage: man_display_page
# Display either the manpage or catpage depending on the use_cat variable
man_display_page_groff() {
local EQN NROFF PIC TBL TROFF REFER VGRIND
local IFS l nroff_dev pipeline preproc_arg tool
# So, we really do need to parse the manpage. First, figure out the
# device flag (-T) we have to pass to eqn(1) and groff(1). Then,
# setup the pipeline of commands based on the user's request.