1
1
<?xml version="1.0" encoding="utf-8"?>
6
# Copyright Ericsson AB 2009. All Rights Reserved.
6
# Copyright Ericsson AB 2009-2011. All Rights Reserved.
8
8
# The contents of this file are subject to the Erlang Public License,
9
9
# Version 1.1, (the "License"); you may not use this file except in
10
10
# compliance with the License. You should have received a copy of the
11
11
# Erlang Public License along with this software. If not, it can be
12
12
# retrieved online at http://www.erlang.org/.
14
14
# Software distributed under the License is distributed on an "AS IS"
15
15
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16
16
# the License for the specific language governing rights and limitations
17
17
# under the License.
23
23
<xsl:stylesheet version="1.0"
24
24
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
25
xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
25
xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
27
27
<xsl:include href="db_html_params.xsl"/>
29
<!-- Start of Dialyzer type/spec tags.
30
See also the template matching "name" and the template "menu.funcs"
33
<xsl:param name="specs_file" select="''"/>
34
<xsl:variable name="i" select="document($specs_file)"></xsl:variable>
36
<xsl:param name="mod2app_file" select="''"/>
37
<xsl:variable name="m2a" select="document($mod2app_file)"></xsl:variable>
38
<xsl:key name="mod2app" match="module" use="@name"/>
40
<xsl:template name="err">
45
<xsl:message terminate="yes">
46
Error <xsl:if test="$m != ''"><xsl:value-of select ="$m"/>:</xsl:if>
48
select="$n"/>/<xsl:value-of
49
select="$a"/>: <xsl:value-of select="$s"/>
53
<xsl:template name="spec_name">
54
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
55
<xsl:variable name="mod" select="@mod"/>
56
<xsl:variable name="name" select="@name"/>
57
<xsl:variable name="arity" select="@arity"/>
58
<xsl:variable name="clause" select="@clause"/>
59
<xsl:variable name="spec0" select=
60
"$i/specs/module[@name=$curModule]/spec
61
[name=$name and arity=$arity
62
and (string-length($mod) = 0 or module = $mod)]"/>
63
<xsl:variable name="spec" select="$spec0[string-length($clause) = 0
64
or position() = $clause]"/>
65
<xsl:if test="count($spec) = 0">
66
<xsl:call-template name="err">
67
<xsl:with-param name="m" select="$mod"/>
68
<xsl:with-param name="n" select="$name"/>
69
<xsl:with-param name="a" select="$arity"/>
70
<xsl:with-param name="s">unknown spec</xsl:with-param>
74
<xsl:variable name="arity_clause">
76
<xsl:when test="string-length(@clause) > 0">
77
<xsl:value-of select="@arity"/>/<xsl:value-of select="@clause"/>
80
<xsl:value-of select="@arity"/>
86
<xsl:when test="ancestor::cref">
87
<xsl:message terminate="yes">
88
Error: did not expect a 'name' tag with name/arity attributes here!
91
<xsl:when test="ancestor::erlref">
92
<a name="{$name}-{$arity_clause}"></a>
94
<xsl:when test="string(@with_guards) = 'no'">
95
<xsl:apply-templates select="$spec/contract/clause/head"/>
98
<xsl:call-template name="contract">
99
<xsl:with-param name="contract" select="$spec/contract"/>
107
<xsl:template name="contract">
108
<xsl:param name="contract"/>
109
<xsl:call-template name="clause">
110
<xsl:with-param name="clause" select="$contract/clause"/>
114
<xsl:template name="clause">
115
<xsl:param name="clause"/>
116
<xsl:variable name="type_desc" select="../type_desc"/>
117
<xsl:for-each select="$clause">
118
<xsl:apply-templates select="head"/>
119
<xsl:if test="count(guard) > 0">
120
<xsl:call-template name="guard">
121
<xsl:with-param name="guard" select="guard"/>
122
<xsl:with-param name="type_desc" select="$type_desc"/>
128
<xsl:template match="head">
129
<span class="bold_code">
130
<xsl:apply-templates/>
135
<xsl:template name="guard">
136
<xsl:param name="guard"/>
137
<xsl:param name="type_desc"/>
138
<div class="REFBODY"><p>Types:</p>
139
<xsl:call-template name="subtype">
140
<xsl:with-param name="subtype" select="$guard/subtype"/>
141
<xsl:with-param name="type_desc" select="$type_desc"/>
146
<xsl:template name="subtype">
147
<xsl:param name="subtype"/>
148
<xsl:param name="type_desc"/>
149
<xsl:for-each select="$subtype">
150
<xsl:variable name="tname" select="typename"/>
151
<xsl:variable name="tdesc" select="$type_desc[@name = $tname]"/>
152
<div class="REFTYPES">
153
<span class="bold_code">
154
<xsl:apply-templates select="string"/>
157
<xsl:apply-templates select="$type_desc[@name = $tname]"/>
161
<!-- Note: <type_desc> has not been implemented for data types. -->
163
<!-- Similar to <d> -->
164
<xsl:template match="type_desc">
165
<div class="REFBODY">
166
<xsl:apply-templates/>
170
<!-- This is for debugging. All modules! -->
171
<xsl:template match="all_etypes">
172
<xsl:for-each select= "$i//type">
174
<span class="bold_code">
175
<xsl:apply-templates select="typedecl"/>
183
<xsl:template match="datatypes">
185
<xsl:text>DATA TYPES</xsl:text>
187
<xsl:apply-templates/>
191
<xsl:template match="datatype">
192
<p><xsl:apply-templates select="name"/></p>
193
<xsl:apply-templates select="desc"/>
196
<xsl:template match="typehead">
197
<span class="bold_code">
198
<xsl:apply-templates/>
203
<xsl:template match="local_defs">
204
<div class="REFBODY">
205
<xsl:apply-templates>
206
</xsl:apply-templates>
210
<xsl:template match="local_def">
211
<div class="REFTYPES">
212
<span class="bold_code">
213
<xsl:apply-templates/>
218
<xsl:template name="type_name">
219
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
220
<xsl:variable name="mod" select="@mod"/>
221
<xsl:variable name="name" select="@name"/>
222
<xsl:variable name="n_vars">
224
<xsl:when test="string-length(@n_vars) > 0">
225
<xsl:value-of select="@n_vars"/>
228
<xsl:value-of select="0"/>
234
<xsl:when test="string-length($name) > 0">
235
<xsl:variable name="type" select=
236
"$i/specs/module[@name=$curModule]/type
237
[name=$name and n_vars=$n_vars
238
and (string-length($mod) = 0 or module = $mod)]"/>
240
<xsl:if test="count($type) != 1">
241
<xsl:call-template name="err">
242
<xsl:with-param name="m" select="$mod"/>
243
<xsl:with-param name="n" select="$name"/>
244
<xsl:with-param name="a" select="$n_vars"/>
245
<xsl:with-param name="s">unknown type</xsl:with-param>
248
<xsl:apply-templates select="$type/typedecl"/>
251
<span class="bold_code">
252
<xsl:value-of select="."/>
258
<!-- Used both in <datatype> and in <func>! -->
259
<xsl:template match="anno">
260
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
261
<xsl:variable name="anno" select="normalize-space(text())"/>
262
<xsl:variable name="namespec"
263
select="ancestor::desc/preceding-sibling::name"/>
264
<xsl:if test="count($namespec) = 0 and string-length($specs_file) > 0">
265
<xsl:call-template name="err">
266
<xsl:with-param name="s">cannot find 'name' (<xsl:value-of select="$anno"/>)
271
<xsl:variable name="mod" select="$namespec/@mod"/>
272
<xsl:variable name="name" select="$namespec/@name"/>
273
<xsl:variable name="arity" select="$namespec/@arity"/>
274
<xsl:variable name="clause" select="$namespec/@clause"/>
275
<xsl:variable name="tmp_n_vars" select="$namespec/@n_vars"/>
276
<xsl:variable name="n_vars">
278
<xsl:when test="string-length($tmp_n_vars) > 0">
279
<xsl:value-of select="$tmp_n_vars"/>
282
<xsl:value-of select="0"/>
286
<xsl:variable name="spec0" select=
287
"$i/specs/module[@name=$curModule]/spec
288
[name=$name and arity=$arity
289
and (string-length($mod) = 0 or module = $mod)]"/>
290
<xsl:variable name="spec_annos" select=
291
"$spec0[string-length($clause) = 0
292
or position() = $clause]/anno[.=$anno]"/>
293
<xsl:variable name="type_annos" select=
294
"$i/specs/module[@name=$curModule]/type
295
[name=$name and n_vars=$n_vars
296
and (string-length($mod) = 0 or module = $mod)]/anno[.=$anno]"/>
298
<xsl:if test="count($spec_annos) = 0
299
and count($type_annos) = 0
300
and string-length($specs_file) > 0">
301
<xsl:variable name="n">
303
<xsl:when test="string-length($arity) = 0">
304
<xsl:value-of select="$n_vars"/>
307
<xsl:value-of select="$arity"/>
311
<xsl:call-template name="err">
312
<xsl:with-param name="m" select="$mod"/>
313
<xsl:with-param name="n" select="$name"/>
314
<xsl:with-param name="a" select="$n"/>
315
<xsl:with-param name="s">unknown annotation <xsl:value-of select="$anno"/>
319
<xsl:value-of select="$anno"/>
322
<!-- Used for indentation of formatted types and specs -->
323
<xsl:template match="nbsp">
324
<xsl:text> </xsl:text>
327
<!-- End of Dialyzer type/spec tags -->
29
329
<!-- Page layout -->
30
330
<xsl:template name="pagelayout">
31
331
<xsl:param name="chapnum"/>
788
1139
<xsl:when test="string-length($fname) > 0">
789
1140
<li title="{$fname}">
790
<a href="{$basename}.html#{$fname}">
791
<xsl:value-of select="$fname"/>()
796
<li title="{name/nametext}">
797
<a href="{$basename}.html#{name/nametext}">
798
<xsl:value-of select="nametext"/>()
805
<xsl:when test="ancestor::erlref">
807
<xsl:variable name="tmpstring">
808
<xsl:value-of select="substring-before(substring-after(., '('), '->')"/>
811
<xsl:variable name="ustring">
813
<xsl:when test="string-length($tmpstring) > 0">
814
<xsl:call-template name="remove-paren">
815
<xsl:with-param name="string" select="$tmpstring"/>
1141
<a href="{$basename}.html#{$fname}">
1142
<xsl:value-of select="$fname"/>()
819
<xsl:call-template name="remove-paren">
820
<xsl:with-param name="string" select="substring-after(., '(')"/>
1147
<li title="{name/nametext}">
1148
<a href="{$basename}.html#{name/nametext}">
1149
<xsl:value-of select="nametext"/>()
822
1152
</xsl:otherwise>
826
<xsl:variable name="arity">
827
<xsl:call-template name="calc-arity">
828
<xsl:with-param name="string" select="substring-before($ustring, ')')"/>
829
<xsl:with-param name="no-of-pars" select="0"/>
832
<xsl:variable name="fname">
833
<xsl:value-of select="substring-before(., '(')"/>
835
<li title="{$fname}-{$arity}">
836
<a href="{$basename}.html#{$fname}-{$arity}">
837
<xsl:value-of select="$fname"/>/<xsl:value-of select="$arity"/>
1156
<xsl:when test="ancestor::erlref">
1158
<xsl:variable name="tmpstring">
1159
<xsl:value-of select="substring-before(substring-after(., '('), '->')"/>
1162
<xsl:variable name="ustring">
1164
<xsl:when test="string-length($tmpstring) > 0">
1165
<xsl:call-template name="remove-paren">
1166
<xsl:with-param name="string" select="$tmpstring"/>
1167
</xsl:call-template>
1170
<xsl:call-template name="remove-paren">
1171
<xsl:with-param name="string" select="substring-after(., '(')"/>
1172
</xsl:call-template>
1177
<xsl:variable name="arity">
1179
<xsl:when test="string-length(@arity) > 0">
1180
<!-- Dialyzer spec -->
1182
<xsl:when test="string-length(@clause) > 0">
1183
<xsl:value-of select="@arity"/>/<xsl:value-of select="@clause"/>
1186
<xsl:value-of select="@arity"/>
1191
<xsl:call-template name="calc-arity">
1192
<xsl:with-param name="string" select="substring-before($ustring, ')')"/>
1193
<xsl:with-param name="no-of-pars" select="0"/>
1194
</xsl:call-template>
1199
<xsl:variable name="fname">
1201
<xsl:when test="string-length(@name) > 0">
1202
<!-- Dialyzer spec -->
1203
<xsl:value-of select="@name"/>
1206
<xsl:variable name="fname1">
1207
<xsl:value-of select="substring-before(., '(')"/>
1209
<xsl:variable name="fname2">
1210
<xsl:value-of select="substring-after($fname1, 'erlang:')"/>
1213
<xsl:when test="string-length($fname2) > 0">
1214
<xsl:value-of select="$fname2"/>
1217
<xsl:value-of select="$fname1"/>
1224
<li title="{$fname}-{$arity}">
1225
<a href="{$basename}.html#{$fname}-{$arity}">
1226
<xsl:value-of select="$fname"/>/<xsl:value-of select="$arity"/>
1089
1479
</xsl:template>
1091
1482
<xsl:template match="name">
1484
<!-- @arity is mandatory when referring to a specification -->
1485
<xsl:when test="string-length(@arity) > 0">
1486
<xsl:call-template name="spec_name"/>
1488
<xsl:when test="ancestor::datatype">
1489
<xsl:call-template name="type_name"/>
1492
<xsl:call-template name="name"/>
1497
<xsl:template name="name">
1093
1499
<xsl:variable name="tmpstring">
1094
1500
<xsl:value-of select="substring-before(substring-after(., '('), '->')"/>
1097
1503
<xsl:variable name="ustring">
1099
1505
<xsl:when test="string-length($tmpstring) > 0">
1100
1506
<xsl:call-template name="remove-paren">
1101
1507
<xsl:with-param name="string" select="$tmpstring"/>
1102
</xsl:call-template>
1508
</xsl:call-template>
1104
1510
<xsl:otherwise>
1105
1511
<xsl:call-template name="remove-paren">
1106
1512
<xsl:with-param name="string" select="substring-after(., '(')"/>
1107
</xsl:call-template>
1513
</xsl:call-template>
1108
1514
</xsl:otherwise>
1112
1518
<xsl:variable name="arity">
1113
1519
<xsl:call-template name="calc-arity">
1114
1520
<xsl:with-param name="string" select="substring-before($ustring, ')')"/>
1115
<xsl:with-param name="no-of-pars" select="0"/>
1521
<xsl:with-param name="no-of-pars" select="0"/>
1116
1522
</xsl:call-template>
1120
1526
<xsl:when test="ancestor::cref">
1121
1527
<a name="{substring-before(nametext, '(')}"><span class="bold_code"><xsl:value-of select="ret"/><xsl:text> </xsl:text><xsl:value-of select="nametext"/></span></a><br/>
1123
1529
<xsl:when test="ancestor::erlref">
1124
<a name="{substring-before(., '(')}-{$arity}"><span class="bold_code"><xsl:value-of select="."/></span></a><br/>
1530
<xsl:variable name="fname">
1531
<xsl:variable name="fname1">
1532
<xsl:value-of select="substring-before(., '(')"/>
1534
<xsl:variable name="fname2">
1535
<xsl:value-of select="substring-after($fname1, 'erlang:')"/>
1538
<xsl:when test="string-length($fname2) > 0">
1539
<xsl:value-of select="$fname2"/>
1542
<xsl:value-of select="$fname1"/>
1546
<a name="{$fname}-{$arity}"><span class="bold_code"><xsl:value-of select="."/></span></a><br/>
1549
<span class="bold_code"><xsl:value-of select="."/></span>
1129
1553
</xsl:template>
1133
1556
<xsl:template match="type">
1134
1557
<xsl:param name="partnum"/>
1136
<div class="REFBODY"><p>Types:</p>
1559
<div class="REFBODY"><p>Types:</p>
1138
1561
<xsl:apply-templates>
1139
1562
<xsl:with-param name="partnum" select="$partnum"/>
1140
1563
</xsl:apply-templates>
1143
1566
</xsl:template>
1459
1904
</xsl:template>
1461
1907
<xsl:template name="remove-paren">
1462
1908
<xsl:param name="string"/>
1464
<xsl:variable name="bstring">
1465
<xsl:value-of select="substring-before($string, '(')"/>
1910
<xsl:variable name="str1">
1911
<xsl:call-template name="remove-paren-1">
1912
<xsl:with-param name="string" select="$string"/>
1913
<xsl:with-param name="start">(</xsl:with-param>
1914
<xsl:with-param name="end">)</xsl:with-param>
1915
</xsl:call-template>
1918
<xsl:variable name="str2">
1919
<xsl:call-template name="remove-paren-1">
1920
<xsl:with-param name="string" select="$str1"/>
1921
<xsl:with-param name="start">{</xsl:with-param>
1922
<xsl:with-param name="end">}</xsl:with-param>
1923
</xsl:call-template>
1926
<xsl:variable name="str3">
1927
<xsl:call-template name="remove-paren-1">
1928
<xsl:with-param name="string" select="$str2"/>
1929
<xsl:with-param name="start">[</xsl:with-param>
1930
<xsl:with-param name="end">]</xsl:with-param>
1931
</xsl:call-template>
1934
<xsl:value-of select="$str3"/>
1939
<xsl:template name="remove-paren-1">
1940
<xsl:param name="string"/>
1941
<xsl:param name="start"/>
1942
<xsl:param name="end"/>
1944
<xsl:variable name="tmp1">
1945
<xsl:value-of select="substring-before($string, $start)"/>
1466
1946
</xsl:variable>
1469
<xsl:when test="string-length($bstring) > 0">
1470
<xsl:variable name="astring">
1471
<xsl:value-of select="substring-after($string, ')')"/>
1949
<xsl:when test="string-length($tmp1) > 0 or starts-with($string, $start)">
1950
<xsl:variable name="tmp2">
1951
<xsl:value-of select="substring-after($string, $end)"/>
1472
1952
</xsl:variable>
1473
1953
<xsl:variable name="retstring">
1474
1954
<xsl:call-template name="remove-paren">
1475
<xsl:with-param name="string" select="$astring"/>
1476
</xsl:call-template>
1955
<xsl:with-param name="string" select="$tmp2"/>
1956
</xsl:call-template>
1477
1957
</xsl:variable>
1478
<xsl:value-of select="concat($bstring, $retstring)"/>
1958
<xsl:value-of select="concat(concat($tmp1, 'x'), $retstring)"/>
1480
1960
<xsl:otherwise>
1481
1961
<xsl:value-of select="$string"/>
1482
1962
</xsl:otherwise>
1484
1965
</xsl:template>
1486
1967
</xsl:stylesheet>