1
1
<?xml version="1.0" encoding="utf-8"?>
6
# Copyright Ericsson AB 2009. All Rights Reserved.
6
# Copyright Ericsson AB 2009-2010. 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
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
24
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
26
26
<xsl:preserve-space elements="code pre"/>
27
27
<xsl:strip-space elements="*"/>
28
28
<xsl:output method="text" encoding="UTF-8" indent="no"/>
30
<!-- Start of Dialyzer type/spec tags. See also the template matching "name"
33
<!-- Note: specs data for *one* module (as opposed to html and pdf) -->
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/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">
79
<xsl:when test="string(@with_guards) = 'no'">
80
<xsl:apply-templates select="$spec/contract/clause/head"/>
83
<xsl:call-template name="contract">
84
<xsl:with-param name="contract" select="$spec/contract"/>
88
<xsl:text> .br</xsl:text>
93
<xsl:template name="contract">
94
<xsl:param name="contract"/>
95
<xsl:call-template name="clause">
96
<xsl:with-param name="clause" select="$contract/clause"/>
100
<xsl:template name="clause">
101
<xsl:param name="clause"/>
102
<xsl:variable name="type_desc" select="../type_desc"/>
103
<xsl:for-each select="$clause">
104
<xsl:apply-templates select="head"/>
105
<xsl:if test="count(guard) > 0">
106
<xsl:call-template name="guard">
107
<xsl:with-param name="guard" select="guard"/>
108
<xsl:with-param name="type_desc" select="$type_desc"/>
114
<xsl:template match="head">
115
<xsl:text> .nf </xsl:text>
116
<xsl:text> .B </xsl:text>
117
<xsl:apply-templates/>
118
<xsl:text> .br</xsl:text>
119
<xsl:text> .fi</xsl:text>
122
<xsl:template name="guard">
123
<xsl:param name="guard"/>
124
<xsl:param name="type_desc"/>
125
<xsl:text> .RS</xsl:text>
126
<xsl:text> .TP</xsl:text>
127
<xsl:text> Types</xsl:text>
128
<xsl:call-template name="subtype">
129
<xsl:with-param name="subtype" select="$guard/subtype"/>
130
<xsl:with-param name="type_desc" select="$type_desc"/>
132
<xsl:text> .RE</xsl:text>
135
<xsl:template name="subtype">
136
<xsl:param name="subtype"/>
137
<xsl:param name="type_desc"/>
138
<xsl:for-each select="$subtype">
139
<xsl:variable name="tname" select="typename"/>
140
<xsl:variable name="tdesc" select="$type_desc[@name = $tname]"/>
141
<xsl:text> </xsl:text>
142
<xsl:apply-templates select="string"/>
143
<xsl:text> .br</xsl:text>
144
<xsl:apply-templates select="$type_desc[@name = $tname]"/>
148
<!-- Note: <type_desc> has not been implemented for data types. -->
150
<!-- Similar to <d> -->
151
<xsl:template match="type_desc">
152
<xsl:text> </xsl:text><xsl:apply-templates/>
153
<xsl:text> .br</xsl:text>
157
<xsl:template match="datatypes">
158
<xsl:text> .SH DATA TYPES</xsl:text>
159
<xsl:apply-templates/>
163
<xsl:template match="datatype">
164
<xsl:apply-templates/>
167
<xsl:template match="typehead">
168
<xsl:text> .nf </xsl:text>
169
<xsl:text> .B </xsl:text>
170
<xsl:apply-templates/>
171
<xsl:text> .br</xsl:text>
172
<xsl:text> .fi</xsl:text>
175
<xsl:template match="local_defs">
176
<xsl:text> .RS</xsl:text>
177
<xsl:apply-templates/>
178
<xsl:text> .RE</xsl:text>
181
<xsl:template match="local_def">
182
<xsl:text> </xsl:text>
183
<xsl:apply-templates/>
184
<xsl:text> .br</xsl:text>
187
<xsl:template name="type_name">
188
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
189
<xsl:variable name="mod" select="@mod"/>
190
<xsl:variable name="name" select="@name"/>
191
<xsl:variable name="n_vars">
193
<xsl:when test="string-length(@n_vars) > 0">
194
<xsl:value-of select="@n_vars"/>
197
<xsl:value-of select="0"/>
203
<xsl:when test="string-length($name) > 0">
204
<xsl:variable name="type" select=
205
"$i/module[@name=$curModule]/type
206
[name=$name and n_vars=$n_vars
207
and (string-length($mod) = 0 or module = $mod)]"/>
209
<xsl:if test="count($type) != 1">
210
<xsl:call-template name="err">
211
<xsl:with-param name="m" select="$mod"/>
212
<xsl:with-param name="n" select="$name"/>
213
<xsl:with-param name="a" select="$n_vars"/>
214
<xsl:with-param name="s">unknown type</xsl:with-param>
217
<xsl:apply-templates select="$type/typedecl"/>
220
<xsl:text> .nf </xsl:text>
221
<xsl:text> .B </xsl:text>
222
<xsl:apply-templates/>
223
<xsl:text> .br</xsl:text>
224
<xsl:text> .fi</xsl:text>
229
<!-- Used both in <datatype> and in <func>! -->
230
<xsl:template match="anno">
231
<xsl:variable name="curModule" select="ancestor::erlref/module"/>
232
<xsl:variable name="anno" select="normalize-space(text())"/>
233
<xsl:variable name="namespec"
234
select="ancestor::desc/preceding-sibling::name"/>
235
<xsl:if test="count($namespec) = 0 and string-length($specs_file) > 0">
236
<xsl:call-template name="err">
237
<xsl:with-param name="s">cannot find 'name' (<xsl:value-of select="$anno"/>)
242
<xsl:variable name="mod" select="$namespec/@mod"/>
243
<xsl:variable name="name" select="$namespec/@name"/>
244
<xsl:variable name="arity" select="$namespec/@arity"/>
245
<xsl:variable name="clause" select="$namespec/@clause"/>
246
<xsl:variable name="tmp_n_vars" select="$namespec/@n_vars"/>
247
<xsl:variable name="n_vars">
249
<xsl:when test="string-length($tmp_n_vars) > 0">
250
<xsl:value-of select="$tmp_n_vars"/>
253
<xsl:value-of select="0"/>
257
<xsl:variable name="spec0" select=
258
"$i/module[@name=$curModule]/spec
259
[name=$name and arity=$arity
260
and (string-length($mod) = 0 or module = $mod)]"/>
261
<xsl:variable name="spec_annos" select=
262
"$spec0[string-length($clause) = 0
263
or position() = $clause]/anno[.=$anno]"/>
264
<xsl:variable name="type_annos" select=
265
"$i/module[@name=$curModule]/type
266
[name=$name and n_vars=$n_vars
267
and (string-length($mod) = 0 or module = $mod)]/anno[.=$anno]"/>
269
<xsl:if test="count($spec_annos) = 0
270
and count($type_annos) = 0
271
and string-length($specs_file) > 0">
272
<xsl:variable name="n">
274
<xsl:when test="string-length($arity) = 0">
275
<xsl:value-of select="$n_vars"/>
278
<xsl:value-of select="$arity"/>
282
<xsl:call-template name="err">
283
<xsl:with-param name="m" select="$mod"/>
284
<xsl:with-param name="n" select="$name"/>
285
<xsl:with-param name="a" select="$n"/>
286
<xsl:with-param name="s">unknown annotation <xsl:value-of select="$anno"/>
290
<xsl:value-of select="$anno"/>
293
<!-- Used for indentation of formatted types and specs -->
294
<xsl:template match="nbsp">
295
<xsl:text> </xsl:text>
298
<!-- End of Dialyzer type/spec tags -->
31
301
<xsl:template match="header">
34
304
<!-- Section/Title -->
35
305
<xsl:template match="section/title">
38
308
<!-- *ref/Section -->
39
309
<xsl:template match="erlref/section|comref/section|cref/section|fileref/section|appref/section">
40
<xsl:text> .RE </xsl:text>
41
310
<xsl:text> .SH "</xsl:text><xsl:value-of select="translate(title, 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:text>" </xsl:text>
42
311
<xsl:apply-templates/>
45
314
<!-- *ref/Subsection -->
46
<xsl:template match="erlref/section/section|comref/section/section|cref/section/section|fileref/section/section|appref/section/section">
47
<xsl:text> .RE </xsl:text>
315
<xsl:template match="section/section">
48
316
<xsl:text> .SS "</xsl:text><xsl:value-of select="title"/><xsl:text>" </xsl:text>
49
317
<xsl:apply-templates/>
55
323
<xsl:template match="list">
56
<xsl:text> .RS 2 </xsl:text>
324
<xsl:text> .RS 2</xsl:text>
57
325
<xsl:apply-templates/>
58
326
<xsl:text> .RE </xsl:text>
188
441
<xsl:template match="application">
189
442
<xsl:apply-templates/>
193
446
<xsl:template match="/erlref">
194
<xsl:text>.TH </xsl:text><xsl:value-of select="module"/><xsl:text> 3 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "Ericsson AB" "Erlang Module Definition" </xsl:text>
195
<xsl:text>.SH MODULE </xsl:text>
196
<xsl:value-of select="module"/><xsl:text> \- </xsl:text><xsl:value-of select="modulesummary"/><xsl:text> </xsl:text>
197
<xsl:apply-templates/>
447
<xsl:variable name="companyname">
449
<!-- Workaround until all of OTP's .../holder contents are correct. -->
450
<xsl:when test="starts-with(header/copyright/holder,'Ericsson AB')"><xsl:text>Ericsson AB</xsl:text></xsl:when>
451
<xsl:otherwise><xsl:value-of select="header/copyright/holder"/></xsl:otherwise>
455
<xsl:text>.TH </xsl:text><xsl:value-of select="module"/><xsl:text> 3 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "</xsl:text><xsl:value-of select="$companyname"/><xsl:text>" "Erlang Module Definition" </xsl:text>
456
<xsl:text>.SH NAME </xsl:text>
457
<xsl:value-of select="module"/><xsl:text> \- </xsl:text><xsl:value-of select="modulesummary"/><xsl:text> </xsl:text>
458
<xsl:apply-templates/>
201
462
<xsl:template match="/comref">
202
<xsl:text>.TH </xsl:text><xsl:value-of select="com"/><xsl:text> 1 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "Ericsson AB" "User Commands" </xsl:text>
203
<xsl:text>.SH NAME </xsl:text>
204
<xsl:value-of select="com"/><xsl:text> \- </xsl:text><xsl:value-of select="comsummary"/><xsl:text> </xsl:text>
205
<xsl:apply-templates/>
463
<xsl:variable name="companyname">
465
<!-- Workaround until all of OTP's .../holder contents are correct. -->
466
<xsl:when test="starts-with(header/copyright/holder,'Ericsson AB')"><xsl:text>Ericsson AB</xsl:text></xsl:when>
467
<xsl:otherwise><xsl:value-of select="header/copyright/holder"/></xsl:otherwise>
470
<xsl:text>.TH </xsl:text><xsl:value-of select="com"/><xsl:text> 1 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "</xsl:text><xsl:value-of select="$companyname"/><xsl:text>" "User Commands" </xsl:text>
471
<xsl:text>.SH NAME </xsl:text>
472
<xsl:value-of select="com"/><xsl:text> \- </xsl:text><xsl:value-of select="comsummary"/><xsl:text> </xsl:text>
473
<xsl:apply-templates/>
209
477
<xsl:template match="/cref">
210
<xsl:text>.TH </xsl:text><xsl:value-of select="lib"/><xsl:text> 3 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "Ericsson AB" "C Library Functions" </xsl:text>
211
<xsl:text>.SH NAME </xsl:text>
212
<xsl:value-of select="lib"/><xsl:text> \- </xsl:text><xsl:value-of select="libsummary"/><xsl:text> </xsl:text>
213
<xsl:apply-templates/>
478
<xsl:variable name="companyname">
480
<!-- Workaround until all of OTP's .../holder contents are correct. -->
481
<xsl:when test="starts-with(header/copyright/holder,'Ericsson AB')"><xsl:text>Ericsson AB</xsl:text></xsl:when>
482
<xsl:otherwise><xsl:value-of select="header/copyright/holder"/></xsl:otherwise>
485
<xsl:text>.TH </xsl:text><xsl:value-of select="lib"/><xsl:text> 3 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "</xsl:text><xsl:value-of select="$companyname"/><xsl:text>" "C Library Functions" </xsl:text>
486
<xsl:text>.SH NAME </xsl:text>
487
<xsl:value-of select="lib"/><xsl:text> \- </xsl:text><xsl:value-of select="libsummary"/><xsl:text> </xsl:text>
488
<xsl:apply-templates/>
217
492
<xsl:template match="/fileref">
218
<xsl:text>.TH </xsl:text><xsl:value-of select="file"/><xsl:text> 4 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "Ericsson AB" "Files" </xsl:text>
219
<xsl:text>.SH NAME </xsl:text>
220
<xsl:value-of select="file"/><xsl:text> \- </xsl:text><xsl:value-of select="filesummary"/><xsl:text> </xsl:text>
221
<xsl:apply-templates/>
493
<xsl:variable name="companyname">
495
<!-- Workaround until all of OTP's .../holder contents are correct. -->
496
<xsl:when test="starts-with(header/copyright/holder,'Ericsson AB')"><xsl:text>Ericsson AB</xsl:text></xsl:when>
497
<xsl:otherwise><xsl:value-of select="header/copyright/holder"/></xsl:otherwise>
500
<xsl:text>.TH </xsl:text><xsl:value-of select="file"/><xsl:text> 5 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "</xsl:text><xsl:value-of select="$companyname"/><xsl:text>" "Files" </xsl:text>
501
<xsl:text>.SH NAME </xsl:text>
502
<xsl:value-of select="file"/><xsl:text> \- </xsl:text><xsl:value-of select="filesummary"/><xsl:text> </xsl:text>
503
<xsl:apply-templates/>
225
507
<xsl:template match="/appref">
226
<xsl:text>.TH </xsl:text><xsl:value-of select="app"/><xsl:text> 6 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "Ericsson AB" "Erlang Application Definition" </xsl:text>
227
<xsl:text>.SH NAME </xsl:text>
228
<xsl:value-of select="file"/><xsl:text> \- </xsl:text><xsl:value-of select="filesummary"/><xsl:text> </xsl:text>
229
<xsl:apply-templates/>
508
<xsl:variable name="companyname">
510
<!-- Workaround until all of OTP's .../holder contents are correct. -->
511
<xsl:when test="starts-with(header/copyright/holder,'Ericsson AB')"><xsl:text>Ericsson AB</xsl:text></xsl:when>
512
<xsl:otherwise><xsl:value-of select="header/copyright/holder"/></xsl:otherwise>
515
<xsl:text>.TH </xsl:text><xsl:value-of select="app"/><xsl:text> 7 "</xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/><xsl:text>" "</xsl:text><xsl:value-of select="$companyname"/><xsl:text>" "Erlang Application Definition" </xsl:text>
516
<xsl:text>.SH NAME </xsl:text>
517
<xsl:value-of select="app"/><xsl:text> \- </xsl:text><xsl:value-of select="appsummary"/><xsl:text> </xsl:text>
518
<xsl:apply-templates/>
232
521
<!-- Module|Com|Lib|File|App-->
297
602
<!-- This tag is skipped for now. -->
300
<!-- xsl:template match="p/text()">
301
<xsl:value-of select="normalize-space()"/>
304
<xsl:template match="d/text()">
305
<xsl:value-of select="normalize-space()"/>
607
<xsl:template match="authors">
608
<xsl:text> .SH AUTHORS</xsl:text>
609
<xsl:apply-templates/>
613
<xsl:template match="authors/aname">
614
<xsl:text> .LP </xsl:text>
615
<xsl:apply-templates/>
619
<xsl:template match="authors/email">
620
<xsl:text> .I <</xsl:text>
621
<xsl:apply-templates/>
622
<xsl:text>></xsl:text>
625
<!-- Do not noramlize any text within pre and code tags. -->
626
<xsl:template match="pre/text()">
627
<xsl:call-template name="replace-string">
628
<xsl:with-param name="text" select="." />
629
<xsl:with-param name="replace" select=""\"" />
630
<xsl:with-param name="with" select=""\\"" />
634
<xsl:template match="code/text()">
635
<xsl:call-template name="replace-string">
636
<xsl:with-param name="text" select="." />
637
<xsl:with-param name="replace" select=""\"" />
638
<xsl:with-param name="with" select=""\\"" />
642
<!-- Replace ' by \&' ans . by \&. -->
643
<xsl:template match="text()">
644
<xsl:variable name="startstring">
645
<xsl:value-of select="normalize-space()"/><xsl:text> </xsl:text>
647
<xsl:variable name="rep1">
648
<xsl:call-template name="replace-string">
649
<xsl:with-param name="text" select="$startstring" />
650
<xsl:with-param name="replace" select=""\"" />
651
<xsl:with-param name="with" select=""\\"" />
654
<xsl:variable name="rep2">
655
<xsl:call-template name="replace-string">
656
<xsl:with-param name="text" select="$rep1" />
657
<xsl:with-param name="replace" select=""'"" />
658
<xsl:with-param name="with" select=""\&'"" />
661
<xsl:call-template name="replace-string">
662
<xsl:with-param name="text" select="$rep2" />
663
<xsl:with-param name="replace" select=""."" />
664
<xsl:with-param name="with" select=""\&."" />
668
<!-- Template replace-string is borrowed at http://www.dpawson.co.uk/xsl/sect2/replace.html -->
669
<xsl:template name="replace-string">
670
<xsl:param name="text"/>
671
<xsl:param name="replace"/>
672
<xsl:param name="with"/>
674
<xsl:when test="contains($text,$replace)">
675
<xsl:value-of select="substring-before($text,$replace)"/>
676
<xsl:value-of select="$with"/>
677
<xsl:call-template name="replace-string">
678
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
679
<xsl:with-param name="replace" select="$replace"/>
680
<xsl:with-param name="with" select="$with"/>
684
<xsl:value-of select="$text"/>
308
689
</xsl:stylesheet>