28
28
<xsl:include href="db_pdf_params.xsl"/>
30
<!-- Start of Dialyzer type/spec tags.
31
See also the template matching "name" and the template "bookmarks6"
34
<xsl:param name="specs_file" select="''"/>
35
<xsl:variable name="i" select="document($specs_file)"></xsl:variable>
37
<xsl:template name="err">
42
<xsl:message terminate="yes">
43
Error <xsl:if test="$m != ''"><xsl:value-of select ="$m"/>:</xsl:if>
45
select="$n"/>/<xsl:value-of
46
select="$a"/>: <xsl:value-of select="$s"/>
50
<xsl:template name="spec_name">
51
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
52
<xsl:variable name="mod" select="@mod"/>
53
<xsl:variable name="name" select="@name"/>
54
<xsl:variable name="arity" select="@arity"/>
55
<xsl:variable name="clause" select="@clause"/>
56
<xsl:variable name="spec0" select=
57
"$i/specs/module[@name=$curModule]/spec
58
[name=$name and arity=$arity
59
and (string-length($mod) = 0 or module = $mod)]"/>
60
<xsl:variable name="spec" select="$spec0[string-length($clause) = 0
61
or position() = $clause]"/>
62
<xsl:if test="count($spec) = 0">
63
<xsl:call-template name="err">
64
<xsl:with-param name="m" select="$mod"/>
65
<xsl:with-param name="n" select="$name"/>
66
<xsl:with-param name="a" select="$arity"/>
67
<xsl:with-param name="s">unknown spec</xsl:with-param>
72
<xsl:when test="ancestor::cref">
73
<xsl:message terminate="yes">
74
Error: did not expect a 'name' tag with name/arity attributes here!
77
<xsl:when test="ancestor::erlref">
78
<fo:block id="{generate-id()}">
80
<xsl:when test="string(@with_guards) = 'no'">
81
<xsl:apply-templates select="$spec/contract/clause/head"/>
84
<xsl:call-template name="contract">
85
<xsl:with-param name="contract" select="$spec/contract"/>
94
<xsl:template name="contract">
95
<xsl:param name="contract"/>
96
<xsl:call-template name="clause">
97
<xsl:with-param name="clause" select="$contract/clause"/>
101
<xsl:template name="clause">
102
<xsl:param name="clause"/>
103
<xsl:variable name="type_desc" select="../type_desc"/>
104
<xsl:for-each select="$clause">
105
<xsl:apply-templates select="head"/>
106
<xsl:if test="count(guard) > 0">
107
<xsl:call-template name="guard">
108
<xsl:with-param name="guard" select="guard"/>
109
<xsl:with-param name="type_desc" select="$type_desc"/>
115
<xsl:template match="head">
116
<fo:block xsl:use-attribute-sets="function-name">
117
<xsl:apply-templates/>
121
<xsl:template name="guard">
123
<xsl:text>Types:</xsl:text>
125
<fo:list-block xsl:use-attribute-sets="type-listblock">
126
<xsl:call-template name="subtype">
127
<xsl:with-param name="subtype" select="$guard/subtype"/>
128
<xsl:with-param name="type_desc" select="$type_desc"/>
133
<xsl:template name="subtype">
134
<xsl:param name="subtype"/>
135
<xsl:param name="type_desc"/>
136
<xsl:for-each select="$subtype">
137
<xsl:variable name="tname" select="typename"/>
138
<xsl:variable name="tdesc" select="$type_desc[@name = $tname]"/>
139
<fo:list-item xsl:use-attribute-sets="type-listitem">
140
<fo:list-item-label end-indent="label-end()">
143
</fo:list-item-label>
144
<fo:list-item-body start-indent="body-start()" format="justify">
145
<fo:block font-weight="bold">
146
<xsl:apply-templates select="string"/>
150
<xsl:apply-templates select="$type_desc[@name = $tname]"/>
154
<!-- Note: <type_desc> has not been implemented for data types. -->
156
<!-- Similar to <d> -->
157
<xsl:template match="type_desc">
158
<fo:list-item xsl:use-attribute-sets="type-listitem">
159
<fo:list-item-label end-indent="label-end()"><fo:block></fo:block>
160
</fo:list-item-label>
161
<fo:list-item-body start-indent="body-start()" format="justify">
163
<xsl:apply-templates/>
170
<xsl:template match="datatypes">
171
<fo:block xsl:use-attribute-sets="h3">
172
<xsl:text>Data Types</xsl:text>
174
<xsl:apply-templates/>
178
<xsl:template match="datatype">
179
<fo:block xsl:use-attribute-sets="function-name">
180
<xsl:apply-templates select="name"/>
182
<xsl:apply-templates select="desc"/>
185
<!-- Like <head>... -->
186
<xsl:template match="typehead">
187
<fo:block xsl:use-attribute-sets="function-name">
188
<xsl:apply-templates/>
192
<!-- Like <guard>, except "Types:"... -->
193
<xsl:template match="local_defs">
194
<fo:list-block xsl:use-attribute-sets="type-listblock">
195
<xsl:apply-templates/>
199
<!-- Like <subtype>... -->
200
<xsl:template match="local_def">
201
<fo:list-item xsl:use-attribute-sets="type-listitem">
202
<fo:list-item-label end-indent="label-end()">
205
</fo:list-item-label>
206
<fo:list-item-body start-indent="body-start()" format="justify">
207
<fo:block font-weight="bold">
208
<xsl:apply-templates/>
214
<xsl:template name="type_name">
215
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
216
<xsl:variable name="mod" select="@mod"/>
217
<xsl:variable name="name" select="@name"/>
218
<xsl:variable name="n_vars">
220
<xsl:when test="string-length(@n_vars) > 0">
221
<xsl:value-of select="@n_vars"/>
224
<xsl:value-of select="0"/>
230
<xsl:when test="string-length($name) > 0">
231
<xsl:variable name="type" select=
232
"$i/specs/module[@name=$curModule]/type
233
[name=$name and n_vars=$n_vars
234
and (string-length($mod) = 0 or module = $mod)]"/>
236
<xsl:if test="count($type) != 1">
237
<xsl:call-template name="err">
238
<xsl:with-param name="m" select="$mod"/>
239
<xsl:with-param name="n" select="$name"/>
240
<xsl:with-param name="a" select="$n_vars"/>
241
<xsl:with-param name="s">unknown type</xsl:with-param>
244
<xsl:apply-templates select="$type/typedecl"/>
247
<fo:inline font-weight="bold" xsl:use-attribute-sets="type-listitem">
248
<xsl:value-of select="."/>
254
<!-- Used both in <datatype> and in <func>! -->
255
<xsl:template match="anno">
256
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
257
<xsl:variable name="anno" select="normalize-space(text())"/>
258
<xsl:variable name="namespec"
259
select="ancestor::desc/preceding-sibling::name"/>
260
<xsl:if test="count($namespec) = 0 and string-length($specs_file) > 0">
261
<xsl:call-template name="err">
262
<xsl:with-param name="s">cannot find 'name' (<xsl:value-of select="$anno"/>)
267
<xsl:variable name="mod" select="$namespec/@mod"/>
268
<xsl:variable name="name" select="$namespec/@name"/>
269
<xsl:variable name="arity" select="$namespec/@arity"/>
270
<xsl:variable name="clause" select="$namespec/@clause"/>
271
<xsl:variable name="tmp_n_vars" select="$namespec/@n_vars"/>
272
<xsl:variable name="n_vars">
274
<xsl:when test="string-length($tmp_n_vars) > 0">
275
<xsl:value-of select="$tmp_n_vars"/>
278
<xsl:value-of select="0"/>
282
<xsl:variable name="spec0" select=
283
"$i/specs/module[@name=$curModule]/spec
284
[name=$name and arity=$arity
285
and (string-length($mod) = 0 or module = $mod)]"/>
286
<xsl:variable name="spec_annos" select=
287
"$spec0[string-length($clause) = 0
288
or position() = $clause]/anno[.=$anno]"/>
289
<xsl:variable name="type_annos" select=
290
"$i/specs/module[@name=$curModule]/type
291
[name=$name and n_vars=$n_vars
292
and (string-length($mod) = 0 or module = $mod)]/anno[.=$anno]"/>
294
<xsl:if test="count($spec_annos) = 0
295
and count($type_annos) = 0
296
and string-length($specs_file) > 0">
297
<xsl:variable name="n">
299
<xsl:when test="string-length($arity) = 0">
300
<xsl:value-of select="$n_vars"/>
303
<xsl:value-of select="$arity"/>
307
<xsl:call-template name="err">
308
<xsl:with-param name="m" select="$mod"/>
309
<xsl:with-param name="n" select="$name"/>
310
<xsl:with-param name="a" select="$n"/>
311
<xsl:with-param name="s">unknown annotation <xsl:value-of select="$anno"/>
315
<xsl:value-of select="$anno"/>
318
<!-- Used for indentation of formatted types and specs -->
319
<xsl:template match="nbsp">
320
<xsl:text> </xsl:text>
323
<!-- End of Dialyzer type/spec tags -->
31
325
<xsl:template match="/">
32
326
<xsl:apply-templates select="book"/>
36
330
<xsl:template match="book">
37
331
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
333
<!-- Master pages -->
40
334
<fo:layout-master-set>
41
335
<fo:simple-page-master
42
336
master-name="cover"
399
698
<fo:bookmark internal-destination="{generate-id(.)}" starting-state="hide">
400
699
<xsl:variable name="tmpstring">
401
700
<xsl:value-of select="substring-before(substring-after(., '('), '->')"/>
404
703
<xsl:variable name="ustring">
406
705
<xsl:when test="string-length($tmpstring) > 0">
407
706
<xsl:call-template name="remove-paren">
408
707
<xsl:with-param name="string" select="$tmpstring"/>
412
711
<xsl:call-template name="remove-paren">
413
712
<xsl:with-param name="string" select="substring-after(., '(')"/>
419
718
<xsl:variable name="arity">
420
<xsl:call-template name="calc-arity">
421
<xsl:with-param name="string" select="substring-before($ustring, ')')"/>
422
<xsl:with-param name="no-of-pars" select="0"/>
720
<xsl:when test="string-length(@arity) > 0">
721
<!-- Dialyzer spec -->
722
<xsl:value-of select="@arity"/>
725
<xsl:call-template name="calc-arity">
726
<xsl:with-param name="string" select="substring-before($ustring, ')')"/>
727
<xsl:with-param name="no-of-pars" select="0"/>
733
<xsl:variable name="fname">
735
<xsl:when test="string-length(@name) > 0">
736
<!-- Dialyzer spec -->
737
<xsl:value-of select="@name"/>
740
<xsl:variable name="fname1">
741
<xsl:value-of select="substring-before(., '(')"/>
743
<xsl:variable name="fname2">
744
<xsl:value-of select="substring-after($fname1, 'erlang:')"/>
747
<xsl:when test="string-length($fname2) > 0">
748
<xsl:value-of select="$fname2"/>
751
<xsl:value-of select="$fname1"/>
425
758
<fo:bookmark-title>
426
<xsl:value-of select="substring-before(., '(')"/>/<xsl:value-of select="$arity"/>
759
<xsl:value-of select="$fname"/>/<xsl:value-of select="$arity"/>
427
760
</fo:bookmark-title>
439
772
<xsl:template match="parts">
440
773
<xsl:apply-templates select="part"/>
1104
1472
<xsl:template name="remove-paren">
1105
1473
<xsl:param name="string"/>
1107
<xsl:variable name="bstring">
1108
<xsl:value-of select="substring-before($string, '(')"/>
1475
<xsl:variable name="str1">
1476
<xsl:call-template name="remove-paren-1">
1477
<xsl:with-param name="string" select="$string"/>
1478
<xsl:with-param name="start">(</xsl:with-param>
1479
<xsl:with-param name="end">)</xsl:with-param>
1480
</xsl:call-template>
1483
<xsl:variable name="str2">
1484
<xsl:call-template name="remove-paren-1">
1485
<xsl:with-param name="string" select="$str1"/>
1486
<xsl:with-param name="start">{</xsl:with-param>
1487
<xsl:with-param name="end">}</xsl:with-param>
1488
</xsl:call-template>
1491
<xsl:variable name="str3">
1492
<xsl:call-template name="remove-paren-1">
1493
<xsl:with-param name="string" select="$str2"/>
1494
<xsl:with-param name="start">[</xsl:with-param>
1495
<xsl:with-param name="end">]</xsl:with-param>
1496
</xsl:call-template>
1499
<xsl:value-of select="$str3"/>
1504
<xsl:template name="remove-paren-1">
1505
<xsl:param name="string"/>
1506
<xsl:param name="start"/>
1507
<xsl:param name="end"/>
1509
<xsl:variable name="tmp1">
1510
<xsl:value-of select="substring-before($string, $start)"/>
1109
1511
</xsl:variable>
1112
<xsl:when test="string-length($bstring) > 0">
1113
<xsl:variable name="astring">
1114
<xsl:value-of select="substring-after($string, ')')"/>
1514
<xsl:when test="string-length($tmp1) > 0 or starts-with($string, $start)">
1515
<xsl:variable name="tmp2">
1516
<xsl:value-of select="substring-after($string, $end)"/>
1115
1517
</xsl:variable>
1116
1518
<xsl:variable name="retstring">
1117
1519
<xsl:call-template name="remove-paren">
1118
<xsl:with-param name="string" select="$astring"/>
1119
</xsl:call-template>
1520
<xsl:with-param name="string" select="$tmp2"/>
1521
</xsl:call-template>
1120
1522
</xsl:variable>
1121
<xsl:value-of select="concat($bstring, $retstring)"/>
1523
<xsl:value-of select="concat(concat($tmp1, 'x'), $retstring)"/>
1123
1525
<xsl:otherwise>
1124
1526
<xsl:value-of select="$string"/>
1125
1527
</xsl:otherwise>
1127
1530
</xsl:template>
1129
1532
</xsl:stylesheet>