#! /bin/sh set -e # Check command line. if test ! -d "$1" || test $# -lt 2; then cat <&2 "$0: $1 not found in \$PATH, please install and try again" exit 1 } search_path man search_path markdown search_path ps2pdf # Create dist-docs directory. distdir=dist-docs abs_distdir=`pwd`/dist-docs rm -rf $distdir mkdir $distdir # Install manpages. ${MAKE-make} install-man mandir="$abs_distdir"/man (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 < Open vSwitch $VERSION Documentation

Open vSwitch $VERSION Documentation

Documents

EOF # Add top-level documentation to index.html, giving it .txt extensions so # that the webserver doesn't serve it as Markdown and make your web browser # try to invoke some kind of external helper you don't have installed. # # Also translate documentation to HTML. for file do title=`head -1 "$srcdir/$file"` dir=$distdir/`dirname $file`; test -d "$dir" || mkdir "$dir" case $file in *.md) cp "$srcdir/$file" "$distdir/$file.txt" ln -s $(basename "$file.txt") "$distdir/$file" (cat < $file (Open vSwitch $VERSION) EOF markdown "$distdir/$file.txt" echo "") > "$distdir/$file.html" cat < EOF ;; *) cp "$srcdir/$file" "$distdir/$file" cat < EOF ;; esac done >&3 # Add header for manpages to index.html. cat >&3 <

Manpages

$file $title HTML, plain text
$file $title plain text
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 GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed 's/.//g' > $manpage.txt (echo '
'
      GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed '
s/&/&/g
s//>/g
s,\(.\)\1,\1,g
s,_\(.\),\1,g'
      echo '
' ) > $manpage.html name=`echo $manpage | sed 's/\.\([0-9]\)$/(\1)/'` echo " " done ) >&3 cat >&3 < 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
$namePDF, HTML, plain text