]> git.proxmox.com Git - ovs.git/blame - build-aux/dist-docs
Merge tag 'v2.15.0' into master-dfsg
[ovs.git] / build-aux / dist-docs
CommitLineData
4441a01c
BP
1#! /bin/sh
2
3set -e
4
5# Check command line.
32dddce8 6if test ! -d "$1" || test $# != 1; then
4441a01c
BP
7 cat <<EOF
8$0: HTML documentation generator for Open vSwitch
32dddce8 9usage: $0 srcdir
4441a01c
BP
10
11The VERSION environment variable should be set to the Open vSwitch version.
12Must be invoked from an Open vSwitch build directory.
13Most conveniently invoked via "make dist-docs".
14EOF
15 exit 1
16fi
17
18# Parse command line.
19srcdir=$1
20shift
21
22# Check for programs we'll need.
23search_path () {
24 save_IFS=$IFS
25 IFS=:
26 for dir in $PATH; do
a36bb334
RB
27 IFS=$save_IFS
28 if test -x "$dir/$1"; then
29 return 0
30 fi
4441a01c
BP
31 done
32 IFS=$save_IFS
33 echo >&2 "$0: $1 not found in \$PATH, please install and try again"
34 exit 1
35}
36search_path man
4441a01c
BP
37search_path ps2pdf
38
39# Create dist-docs directory.
40distdir=dist-docs
41abs_distdir=`pwd`/dist-docs
42rm -rf $distdir
43mkdir $distdir
44
45# Install manpages.
02290df9 46${MAKE-make} install-man install-man-rst mandir="$abs_distdir"/man
4441a01c
BP
47(cd $distdir && mv `find man -type f` . && rm -rf man)
48manpages=`cd $distdir && echo *`
49
50# Start writing index.html.
51exec 3>$distdir/index.html
52cat >&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>
c431227e 58<h1>Open vSwitch $VERSION Manpages</h1>
4441a01c
BP
59<table>
60EOF
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
0e7850eb 69 GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed 's/.\b//g' > $manpage.txt
4441a01c 70 (echo '<html><head><meta charset="UTF-8"></head><body><pre>'
0e7850eb 71 GROFF_NO_SGR=1 man -l -Tutf8 $manpage | sed '
cfc06fb1
BP
72# Change bold and underline via backspacing into bracketing with control
73# characters. We cannot directly translate them to HTML because <> need
74# to be escaped later. (We cannot escape <> first because bold or
75# underlined escaped characters would be mis-processed.)
76s,\(.\)\b\1,\ 1\1\ 2,g
77s,_\b\(.\),\ 3\1\ 4,g
78
79# Drop redundant font changes, to keep from having every character have
80# a separate tag pair.
81s,\ 2\ 1,,g
82s,\ 4\ 3,,g
83
84# Escape special characters.
85s,&,\&amp;,g
86s,<,\&lt;,g
87s,>,\&gt;,g
88
89# Translate control characters to HTML.
90s,\ 1,<b>,g
91s,\ 2,</b>,g
92s,\ 3,<u>,g
93s,\ 4,</u>,g
94'
4441a01c
BP
95 echo '</pre></body></html>'
96 ) > $manpage.html
97
98 name=`echo $manpage | sed 's/\.\([0-9]\)$/(\1)/'`
99 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>"
100 done
101) >&3
102cat >&3 <<EOF
103</table>
104</body></html>
105EOF
106
107# Create CSS style file.
108cat >$distdir/style.css <<'EOF'
109div { vertical-align:top; }
110p {
111 vertical-align:baseline;
112}
113a {
114 text-decoration: none;
115 font-weight: 700;
116}
117a:hover {
118 color:#444;
119}
120a:visited {
121 color:#447099;
122}
123a:link {
124 color:#447099;
125}
126
127body {
128 font-family: Arial,Helvetica,sans-serif;
129 font-size: 14px;
130 line-height: 1.5em;
131 color: #444;
132 background-color:#f5f5f5;
133}
134EOF