-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathotp.gen.doc.index
More file actions
executable file
·159 lines (146 loc) · 5.02 KB
/
otp.gen.doc.index
File metadata and controls
executable file
·159 lines (146 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash -e
# ========================================================================
# Copyright (c) 2015-2017 T. R. Burghart.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ========================================================================
#
# Generate a central documentation index page for an installed OTP instance.
#
readonly sdir="$(cd "$(dirname "$0")" && pwd)"
readonly sname="${0##*/}"
readonly spath="$sdir/$sname"
. "$LOCAL_ENV_DIR/otp.install.base" || exit $?
if [[ $# -ne 1 ]]
then
echo "Usage: $sname local-otp-release-name (under 'local' install path)" >&2
echo " * local install path is '$otp_install_base'" >&2
exit 1
fi
readonly otp_inst_dir="$otp_install_base/$1"
if [[ ! -d "$otp_inst_dir" ]]
then
echo "$sname error: '$otp_inst_dir' is not a directory" >&2
exit 2
fi
. "$LOCAL_ENV_DIR/otp.install.version" || exit $?
cd "$otp_inst_dir"
readonly erts_path="$(ls -1d lib/erlang/erts-* 2>/dev/null | tail -1)"
if [[ -z "$erts_path" || ! -d "$erts_path" ]]
then
echo "$sname error: ERTS not found" >&2
exit 2
fi
readonly erts_vers="${erts_path#lib/erlang/erts-}"
app_path()
{
_ap_name="$1"
_ap_path=$(ls -1d lib/erlang/lib/${_ap_name}-* 2>/dev/null | tail -1)
if [[ -z "$_ap_path" || ! -d "$_ap_path" ]]
then
echo "$sname error: app '$_ap_name' not found" >&2
exit 2
fi
echo "$_ap_path"
}
readonly index_file="$otp_inst_dir/index.html"
readonly href_entry='<a href="%s">%s</a>'
cat <<EOF >"$index_file"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Erlang/OTP $otp_inst_release Documentation</title>
<style type="text/css">
body { margin-top: 0.6in; margin-bottom: 0.6in;
margin-left: 0.8in; margin-right: 0.8in; }
hr { width: 100%; }
table { border: 0; }
th { text-align: left; font-variant: small-caps; }
td { text-align: left; padding-left: 10ex; }
</style>
</head>
<body>
<h2>Erlang/OTP $otp_inst_release Documentation</h2>
<hr>
<h3>General</h3>
<p>
<a href="lib/erlang/doc/index.html">Main</a>
- <a href="lib/erlang/doc/reference_manual/users_guide.html">Reference Manual</a>
- <a href="lib/erlang/doc/reference_manual/typespec.html">Type Specifications</a>
</p>
<hr>
<h3>Quick Access</h3>
<p>
<a href="$erts_path/doc/html/erlang.html">ERTS</a>
- <a href="$(app_path sasl)/doc/html/index.html">SASL</a>
- <a href="$(app_path kernel)/doc/html/index.html">Kernel</a>
- <a href="$(app_path stdlib)/doc/html/index.html">STDLIB</a>
- <a href="$(app_path crypto)/doc/html/crypto.html">Crypto</a>
- <a href="$(app_path compiler)/doc/html/compile.html">Compiler</a>
- <a href="$(app_path eunit)/doc/html/chapter.html">EUnit</a>
- <a href="$(app_path dialyzer)/doc/html/dialyzer.html">Dialyzer</a>
- <a href="$(app_path debugger)/doc/html/debugger_chapter.html">Debugger</a>
</p>
<hr>
<h3>Package Documentation</h3>
<table>
<tbody>
<tr>
<th>Erlang/ERTS</td>
<td>$erts_vers</td>
<td><a href="$erts_path/doc/html/erlang.html">API</a></td>
<td><a href="$erts_path/doc/html/release_notes.html">Release Notes</a></td>
</tr>
EOF
for p in lib/erlang/lib/*-*
do
# allow for packages that don't create an 'html' subdirectory
[[ -d "$p" ]] || continue
if [[ -f "$p/doc/html/index.html" ]]
then
ix_ent="<a href=\"$p/doc/html/index.html\">API</a>"
elif [[ -f "$p/doc/index.html" ]]
then
ix_ent="<a href=\"$p/doc/index.html\">API</a>"
else
unset ix_ent
fi
if [[ -f "$p/doc/html/release_notes.html" ]]
then
rn_ent="<a href=\"$p/doc/html/release_notes.html\">Release Notes</a>"
elif [[ -f "$p/doc/release_notes.html" ]]
then
rn_ent="<a href=\"$p/doc/release_notes.html\">Release Notes</a>"
else
unset rn_ent
fi
[[ -n "$ix_ent" || -n "$rn_ent" ]] || continue
n="${p##*/}"
cat <<EOF
<tr>
<th>${n%%-*}</td>
<td>${n#*-}</td>
<td>${ix_ent}</td>
<td>${rn_ent}</td>
</tr>
EOF
done >>"$index_file"
cat <<EOF >>"$index_file"
</tbody>
</table>
<hr>
</body>
</html>
EOF
echo Wrote "'$index_file'"