]> git.proxmox.com Git - mirror_ovs.git/blob - build-aux/dist-docs
dist-docs: Make "make dist-docs" work again.
[mirror_ovs.git] / build-aux / dist-docs
1 #! /bin/sh
2
3 set -e
4
5 # Check command line.
6 if test ! -d "$1" || test $# != 1; then
7 cat <<EOF
8 $0: HTML documentation generator for Open vSwitch
9 usage: $0 srcdir
10
11 The VERSION environment variable should be set to the Open vSwitch version.
12 Must be invoked from an Open vSwitch build directory.
13 Most conveniently invoked via "make dist-docs".
14 EOF
15 exit 1
16 fi
17
18 # Parse command line.
19 srcdir=$1
20 shift
21
22 # Check for programs we'll need.
23 search_path () {
24 save_IFS=$IFS
25 IFS=:
26 for dir in $PATH; do
27 IFS=$save_IFS
28 if test -x "$dir/$1"; then
29 return 0
30 fi
31 done
32 IFS=$save_IFS
33 echo >&2 "$0: $1 not found in \$PATH, please install and try again"
34 exit 1
35 }
36 search_path man
37 search_path ps2pdf
38
39 # Create dist-docs directory.
40 distdir=dist-docs
41 abs_distdir=`pwd`/dist-docs
42 rm -rf $distdir
43 mkdir $distdir
44
45 # Install manpages.
46 ${MAKE-make} install-man mandir="$abs_distdir"/man
47 (cd $distdir && mv `find man -type f` . && rm -rf man)
48 manpages=`cd $distdir && echo *`
49
50 # Start writing index.html.
51 exec 3>$distdir/index.html
52 cat >&3 <<EOF
53 <html><head>
54 <meta charset="UTF-8"></head>
55 <link rel="stylesheet" type="text/css" href="style.css">
56 <title>Open vSwitch $VERSION Documentation</title>
57 </head><body>
58 <h1>Open vSwitch $VERSION Manpages</h1>
59 <table>
60 EOF
61
62 # Add manpages to index.html, translating them into PDF, HTML, and plain text.
63 # The HTML is just slightly marked up from the plain text version; although
64 # groff supports better HTML output, on my system some of the OVS manpages
65 # cause the groff HTML output engine to segfault (!).
66 (cd $distdir
67 for manpage in $manpages; do
68 man -l -Tps $manpage | ps2pdf - > $manpage.pdf
69 GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed 's/.\b//g' > $manpage.txt
70 (echo '<html><head><meta charset="UTF-8"></head><body><pre>'
71 GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed '
72 s/&/&amp;/g
73 s/</&lt;/g
74 s/>/&gt;/g
75 s,\(.\)\b\1,<b>\1</b>,g
76 s,_\b\(.\),<u>\1</u>,g'
77 echo '</pre></body></html>'
78 ) > $manpage.html
79
80 name=`echo $manpage | sed 's/\.\([0-9]\)$/(\1)/'`
81 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>"
82 done
83 ) >&3
84 cat >&3 <<EOF
85 </table>
86 </body></html>
87 EOF
88
89 # Create CSS style file.
90 cat >$distdir/style.css <<'EOF'
91 div { vertical-align:top; }
92 p {
93 vertical-align:baseline;
94 }
95 a {
96 text-decoration: none;
97 font-weight: 700;
98 }
99 a:hover {
100 color:#444;
101 }
102 a:visited {
103 color:#447099;
104 }
105 a:link {
106 color:#447099;
107 }
108
109 body {
110 font-family: Arial,Helvetica,sans-serif;
111 font-size: 14px;
112 line-height: 1.5em;
113 color: #444;
114 background-color:#f5f5f5;
115 }
116 EOF