2014-12-02 11:04:16 -08:00
|
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Check command line.
|
2016-12-13 12:50:10 -08:00
|
|
|
|
if test ! -d "$1" || test $# != 1; then
|
2014-12-02 11:04:16 -08:00
|
|
|
|
cat <<EOF
|
|
|
|
|
$0: HTML documentation generator for Open vSwitch
|
2016-12-13 12:50:10 -08:00
|
|
|
|
usage: $0 srcdir
|
2014-12-02 11:04:16 -08:00
|
|
|
|
|
|
|
|
|
The VERSION environment variable should be set to the Open vSwitch version.
|
|
|
|
|
Must be invoked from an Open vSwitch build directory.
|
|
|
|
|
Most conveniently invoked via "make dist-docs".
|
|
|
|
|
EOF
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Parse command line.
|
|
|
|
|
srcdir=$1
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
|
|
# Check for programs we'll need.
|
|
|
|
|
search_path () {
|
|
|
|
|
save_IFS=$IFS
|
|
|
|
|
IFS=:
|
|
|
|
|
for dir in $PATH; do
|
2016-02-09 12:53:42 -05:00
|
|
|
|
IFS=$save_IFS
|
|
|
|
|
if test -x "$dir/$1"; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
2014-12-02 11:04:16 -08:00
|
|
|
|
done
|
|
|
|
|
IFS=$save_IFS
|
|
|
|
|
echo >&2 "$0: $1 not found in \$PATH, please install and try again"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
search_path man
|
|
|
|
|
search_path ps2pdf
|
|
|
|
|
|
|
|
|
|
# Create dist-docs directory.
|
|
|
|
|
distdir=dist-docs
|
|
|
|
|
abs_distdir=`pwd`/dist-docs
|
|
|
|
|
rm -rf $distdir
|
|
|
|
|
mkdir $distdir
|
|
|
|
|
|
|
|
|
|
# Install manpages.
|
2021-01-29 14:20:29 +01:00
|
|
|
|
${MAKE-make} install-man install-man-rst mandir="$abs_distdir"/man
|
2014-12-02 11:04:16 -08:00
|
|
|
|
(cd $distdir && mv `find man -type f` . && rm -rf man)
|
|
|
|
|
manpages=`cd $distdir && echo *`
|
|
|
|
|
|
|
|
|
|
# Start writing index.html.
|
|
|
|
|
exec 3>$distdir/index.html
|
|
|
|
|
cat >&3 <<EOF
|
|
|
|
|
<html><head>
|
|
|
|
|
<meta charset="UTF-8"></head>
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
|
|
|
<title>Open vSwitch $VERSION Documentation</title>
|
|
|
|
|
</head><body>
|
2016-12-08 12:55:30 +00:00
|
|
|
|
<h1>Open vSwitch $VERSION Manpages</h1>
|
2014-12-02 11:04:16 -08:00
|
|
|
|
<table>
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# Add manpages to index.html, translating them into PDF, HTML, and plain text.
|
|
|
|
|
# The HTML is just slightly marked up from the plain text version; although
|
|
|
|
|
# groff supports better HTML output, on my system some of the OVS manpages
|
|
|
|
|
# cause the groff HTML output engine to segfault (!).
|
|
|
|
|
(cd $distdir
|
|
|
|
|
for manpage in $manpages; do
|
|
|
|
|
man -l -Tps $manpage | ps2pdf - > $manpage.pdf
|
2015-11-11 08:58:51 -08:00
|
|
|
|
GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed 's/.//g' > $manpage.txt
|
2014-12-02 11:04:16 -08:00
|
|
|
|
(echo '<html><head><meta charset="UTF-8"></head><body><pre>'
|
2015-11-11 08:58:51 -08:00
|
|
|
|
GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed '
|
2019-05-10 15:02:43 -07:00
|
|
|
|
# Change bold and underline via backspacing into bracketing with control
|
|
|
|
|
# characters. We cannot directly translate them to HTML because <> need
|
|
|
|
|
# to be escaped later. (We cannot escape <> first because bold or
|
|
|
|
|
# underlined escaped characters would be mis-processed.)
|
|
|
|
|
s,\(.\)\1,\1,g
|
|
|
|
|
s,_\(.\),\1,g
|
|
|
|
|
|
|
|
|
|
# Drop redundant font changes, to keep from having every character have
|
|
|
|
|
# a separate tag pair.
|
|
|
|
|
s,,,g
|
|
|
|
|
s,,,g
|
|
|
|
|
|
|
|
|
|
# Escape special characters.
|
|
|
|
|
s,&,\&,g
|
|
|
|
|
s,<,\<,g
|
|
|
|
|
s,>,\>,g
|
|
|
|
|
|
|
|
|
|
# Translate control characters to HTML.
|
|
|
|
|
s,,<b>,g
|
|
|
|
|
s,,</b>,g
|
|
|
|
|
s,,<u>,g
|
|
|
|
|
s,,</u>,g
|
|
|
|
|
'
|
2014-12-02 11:04:16 -08:00
|
|
|
|
echo '</pre></body></html>'
|
|
|
|
|
) > $manpage.html
|
|
|
|
|
|
|
|
|
|
name=`echo $manpage | sed 's/\.\([0-9]\)$/(\1)/'`
|
|
|
|
|
echo " <tr><td>$name</td><td><a href=\"$manpage.pdf\">PDF</a>, <a href=\"$manpage.html\">HTML</a>, <a href=\"$manpage.txt\">plain text</a></td></tr>"
|
|
|
|
|
done
|
|
|
|
|
) >&3
|
|
|
|
|
cat >&3 <<EOF
|
|
|
|
|
</table>
|
|
|
|
|
</body></html>
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# Create CSS style file.
|
|
|
|
|
cat >$distdir/style.css <<'EOF'
|
|
|
|
|
div { vertical-align:top; }
|
|
|
|
|
p {
|
|
|
|
|
vertical-align:baseline;
|
|
|
|
|
}
|
|
|
|
|
a {
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
}
|
|
|
|
|
a:hover {
|
|
|
|
|
color:#444;
|
|
|
|
|
}
|
|
|
|
|
a:visited {
|
|
|
|
|
color:#447099;
|
|
|
|
|
}
|
|
|
|
|
a:link {
|
|
|
|
|
color:#447099;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
font-family: Arial,Helvetica,sans-serif;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 1.5em;
|
|
|
|
|
color: #444;
|
|
|
|
|
background-color:#f5f5f5;
|
|
|
|
|
}
|
|
|
|
|
EOF
|