summaryrefslogtreecommitdiffstats
path: root/usr.bin/man
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2014-11-23 00:08:04 +0000
committerbapt <bapt@FreeBSD.org>2014-11-23 00:08:04 +0000
commitc33472c9185d85a8981c8d65109b174d92d16173 (patch)
treec4846c110ff311b935947cecd10ba6445a08b5dd /usr.bin/man
parentfdb2e482eef4ef9885b81593f8ba53c8400978be (diff)
downloadFreeBSD-src-c33472c9185d85a8981c8d65109b174d92d16173.zip
FreeBSD-src-c33472c9185d85a8981c8d65109b174d92d16173.tar.gz
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
Diffstat (limited to 'usr.bin/man')
-rwxr-xr-xusr.bin/man/man.sh48
1 files changed, 44 insertions, 4 deletions
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 0f6249a..ac66eec 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -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.
OpenPOWER on IntegriCloud