summaryrefslogtreecommitdiff
path: root/usr.bin/man
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2014-11-23 00:08:04 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2014-11-23 00:08:04 +0000
commitd6096801f174f387e90ad4d9a0dba9a924d87870 (patch)
treec4846c110ff311b935947cecd10ba6445a08b5dd /usr.bin/man
parentb9cfeb20f63e0e8ec6b3ee599a6ea68a7a752b0e (diff)
downloadsrc-test-d6096801f174f387e90ad4d9a0dba9a924d87870.tar.gz
src-test-d6096801f174f387e90ad4d9a0dba9a924d87870.zip
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
Notes
Notes: svn path=/head/; revision=274901
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 0f6249aee00e9..ac66eec6e75b0 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.