1
<?xml version="1.0" encoding="utf-8"?>
3
Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
5
Distributed under the Boost Software License, Version 1.0.
6
(See accompanying file LICENSE_1_0.txt or copy at
7
http://www.boost.org/LICENSE_1_0.txt)
9
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12
<xsl:param name="template.param.brief" select="false()"/>
14
<!-- Determine the length of a template header synopsis -->
15
<xsl:template name="template.synopsis.length">
16
<xsl:variable name="text">
17
<xsl:apply-templates select="template" mode="synopsis">
18
<xsl:with-param name="indentation" select="0"/>
19
<xsl:with-param name="wrap" select="false()"/>
20
<xsl:with-param name="highlight" select="false()"/>
21
</xsl:apply-templates>
23
<xsl:value-of select="string-length($text)"/>
26
<!-- Determine the length of a template header reference -->
27
<xsl:template name="template.reference.length">
29
<xsl:when test="not(template)">
32
<xsl:when test="template/*/purpose">
33
<!-- TBD: The resulting value need only be greater than the number of
34
columns. We chose to add 17 because it's funny for C++
36
<xsl:value-of select="$max-columns + 17"/>
39
<xsl:call-template name="template.synopsis.length"/>
44
<!-- Output a template header in synopsis mode -->
45
<xsl:template match="template" mode="synopsis">
46
<xsl:param name="indentation" select="0"/>
47
<xsl:param name="wrap" select="true()"/>
48
<xsl:param name="highlight" select="true()"/>
50
<xsl:call-template name="template.synopsis">
51
<xsl:with-param name="indentation" select="$indentation"/>
52
<xsl:with-param name="wrap" select="$wrap"/>
53
<xsl:with-param name="highlight" select="$highlight"/>
57
<!-- Output a template header in reference mode -->
58
<xsl:template match="template" mode="reference">
59
<xsl:param name="indentation" select="0"/>
60
<xsl:param name="highlight" select="true()"/>
61
<xsl:call-template name="template.reference">
62
<xsl:with-param name="indentation" select="$indentation"/>
63
<xsl:with-param name="highlight" select="$highlight"/>
67
<!-- Emit a template header synopsis -->
68
<xsl:template name="template.synopsis">
69
<xsl:param name="indentation" select="0"/>
70
<xsl:param name="wrap" select="true()"/>
71
<xsl:param name="highlight" select="true()"/>
74
<xsl:when test="$highlight">
75
<xsl:call-template name="highlight-keyword">
76
<xsl:with-param name="keyword" select="'template'"/>
78
<xsl:call-template name="highlight-special">
79
<xsl:with-param name="text" select="'<'"/>
83
<xsl:text>template</xsl:text>
84
<xsl:text><</xsl:text>
87
<xsl:call-template name="template.synopsis.parameters">
88
<xsl:with-param name="indentation" select="$indentation + 9"/>
89
<xsl:with-param name="wrap" select="$wrap"/>
90
<xsl:with-param name="highlight" select="$highlight"/>
93
<xsl:when test="$highlight">
94
<xsl:call-template name="highlight-special">
95
<xsl:with-param name="text" select="'>'"/>
97
<xsl:text> </xsl:text>
100
<xsl:text>> </xsl:text>
105
<!-- Display a list of template parameters for a synopsis (no comments) -->
106
<xsl:template name="template.synopsis.parameters">
107
<xsl:param name="indentation"/>
108
<xsl:param name="wrap" select="true()"/>
109
<xsl:param name="highlight" select="true()"/>
111
<xsl:param name="column" select="$indentation"/>
112
<xsl:param name="prefix" select="''"/>
113
<xsl:param name="parameters" select="template-type-parameter|template-varargs|template-nontype-parameter"/>
114
<xsl:param name="first-on-line" select="true()"/>
116
<xsl:if test="$parameters">
117
<!-- Emit the prefix (either a comma-space, or empty if this is
118
the first parameter) -->
120
<xsl:when test="$highlight">
121
<xsl:call-template name="highlight-text">
122
<xsl:with-param name="text" select="$prefix"/>
126
<xsl:value-of select="$prefix"/>
130
<!-- Get the actual parameter and its attributes -->
131
<xsl:variable name="parameter" select="$parameters[position()=1]"/>
132
<xsl:variable name="rest" select="$parameters[position()!=1]"/>
134
<!-- Compute the actual text of this parameter -->
135
<xsl:variable name="text">
136
<xsl:call-template name="template.parameter">
137
<xsl:with-param name="parameter" select="$parameter"/>
138
<xsl:with-param name="is-last" select="not(rest)"/>
139
<xsl:with-param name="highlight" select="false()"/>
143
<!-- Where will this template parameter finish? -->
144
<xsl:variable name="end-column"
145
select="$column + string-length($prefix) + string-length($text)"/>
147
<!-- Should the text go on this line or on the next? -->
149
<xsl:when test="$first-on-line or ($end-column < $max-columns) or
151
<!-- Print on this line -->
152
<xsl:call-template name="template.parameter">
153
<xsl:with-param name="parameter" select="$parameter"/>
154
<xsl:with-param name="is-last" select="not($rest)"/>
155
<xsl:with-param name="highlight" select="$highlight"/>
159
<xsl:call-template name="template.synopsis.parameters">
160
<xsl:with-param name="indentation" select="$indentation"/>
161
<xsl:with-param name="wrap" select="$wrap"/>
162
<xsl:with-param name="highlight" select="$highlight"/>
163
<xsl:with-param name="column" select="$end-column"/>
164
<xsl:with-param name="prefix" select="', '"/>
165
<xsl:with-param name="parameters" select="$rest"/>
166
<xsl:with-param name="first-on-line" select="false()"/>
170
<!-- Print on next line -->
171
<xsl:text> </xsl:text>
172
<xsl:call-template name="indent">
173
<xsl:with-param name="indentation" select="$indentation"/>
175
<xsl:call-template name="template.parameter">
176
<xsl:with-param name="parameter" select="$parameter"/>
177
<xsl:with-param name="is-last" select="not($rest)"/>
178
<xsl:with-param name="highlight" select="$highlight"/>
181
<xsl:call-template name="template.synopsis.parameters">
182
<xsl:with-param name="indentation" select="$indentation"/>
183
<xsl:with-param name="wrap" select="$wrap"/>
184
<xsl:with-param name="highlight" select="$highlight"/>
185
<xsl:with-param name="column"
186
select="$indentation + string-length($text)"/>
187
<xsl:with-param name="prefix" select="', '"/>
188
<xsl:with-param name="parameters" select="$rest"/>
189
<xsl:with-param name="first-on-line" select="false()"/>
196
<!-- Emit a template header reference -->
197
<xsl:template name="template.reference">
198
<xsl:param name="indentation" select="0"/>
199
<xsl:param name="highlight" select="true()"/>
201
<xsl:if test="template-type-parameter|template-varargs|template-nontype-parameter">
203
<xsl:when test="$highlight">
204
<xsl:call-template name="highlight-keyword">
205
<xsl:with-param name="keyword" select="'template'"/>
207
<xsl:call-template name="highlight-special">
208
<xsl:with-param name="text" select="'<'"/>
212
<xsl:text>template</xsl:text>
213
<xsl:text><</xsl:text>
216
<xsl:call-template name="template.reference.parameters">
217
<xsl:with-param name="indentation" select="$indentation + 9"/>
218
<xsl:with-param name="highlight" select="$highlight"/>
221
<xsl:when test="$highlight">
222
<xsl:call-template name="highlight-special">
223
<xsl:with-param name="text" select="'>'"/>
225
<xsl:text> </xsl:text>
228
<xsl:text>> </xsl:text>
234
<!-- Display a set of template parameters for a reference -->
235
<xsl:template name="template.reference.parameters">
236
<xsl:param name="indentation"/>
237
<xsl:param name="highlight" select="true()"/>
238
<xsl:param name="parameters" select="template-type-parameter|template-varargs|template-nontype-parameter"/>
241
<xsl:when test="$parameters/purpose and $template.param.brief">
242
<xsl:call-template name="template.reference.parameters.comments">
243
<xsl:with-param name="indentation" select="$indentation"/>
244
<xsl:with-param name="highlight" select="$highlight"/>
248
<xsl:call-template name="template.synopsis.parameters">
249
<xsl:with-param name="indentation" select="$indentation"/>
250
<xsl:with-param name="wrap" select="true()"/>
251
<xsl:with-param name="highlight" select="$highlight"/>
257
<!-- Output template parameters when there are comments with the parameters.
258
For clarity, we output each template parameter on a separate line. -->
259
<xsl:template name="template.reference.parameters.comments">
260
<xsl:param name="indentation"/>
261
<xsl:param name="highlight" select="true()"/>
262
<xsl:param name="parameters" select="template-type-parameter|template-varargs|template-nontype-parameter"/>
264
<xsl:if test="$parameters">
265
<!-- Get the actual parameter and its attributes -->
266
<xsl:variable name="parameter" select="$parameters[position()=1]"/>
267
<xsl:variable name="rest" select="$parameters[position()!=1]"/>
269
<!-- Display the parameter -->
270
<xsl:call-template name="template.parameter">
271
<xsl:with-param name="parameter" select="$parameter"/>
272
<xsl:with-param name="is-last" select="not($rest)"/>
273
<xsl:with-param name="highlight" select="$highlight"/>
276
<xsl:if test="$rest">
278
<xsl:when test="$highlight">
279
<xsl:call-template name="highlight-text">
280
<xsl:with-param name="text" select="', '"/>
284
<xsl:text>, </xsl:text>
289
<!-- Display the comment -->
290
<xsl:if test="$parameter/purpose">
291
<xsl:variable name="param-text">
292
<!-- Display the parameter -->
293
<xsl:call-template name="template.parameter">
294
<xsl:with-param name="parameter" select="$parameter"/>
295
<xsl:with-param name="is-last" select="not($rest)"/>
296
<xsl:with-param name="highlight" select="false()"/>
299
<xsl:call-template name="highlight-comment">
300
<xsl:with-param name="text">
301
<xsl:text> // </xsl:text>
303
select="$parameter/purpose/*|$parameter/purpose/text()" mode="comment">
304
<xsl:with-param name="wrap" select="true()"/>
305
<xsl:with-param name="prefix">
306
<xsl:call-template name="indent">
307
<xsl:with-param name="indentation" select="$indentation + string-length($param-text)"/>
309
<xsl:if test="$rest">
310
<xsl:text> </xsl:text>
312
<xsl:text> // </xsl:text>
314
</xsl:apply-templates>
319
<!-- Indent the next line -->
320
<xsl:if test="$parameter/purpose or $rest">
321
<xsl:text> </xsl:text>
322
<xsl:call-template name="indent">
323
<xsl:with-param name="indentation" select="$indentation"/>
327
<!-- Recurse to print the rest of the parameters -->
328
<xsl:call-template name="template.reference.parameters.comments">
329
<xsl:with-param name="indentation" select="$indentation"/>
330
<xsl:with-param name="highlight" select="$highlight"/>
331
<xsl:with-param name="parameters" select="$rest"/>
336
<!-- Print a template parameter -->
337
<xsl:template name="template.parameter">
338
<xsl:param name="parameter"/>
339
<xsl:param name="is-last"/>
340
<xsl:param name="highlight" select="true()"/>
341
<xsl:apply-templates select="$parameter"
342
mode="print.parameter">
343
<xsl:with-param name="parameter" select="$parameter"/>
344
<xsl:with-param name="is-last" select="$is-last"/>
345
<xsl:with-param name="highlight" select="$highlight"/>
346
</xsl:apply-templates>
349
<xsl:template name="template.parameter.name">
350
<xsl:param name="name" select="@name"/>
351
<xsl:param name="highlight" select="true()"/>
354
<xsl:when test="$highlight">
355
<xsl:call-template name="concept.link">
356
<xsl:with-param name="name"
357
select="translate($name, '0123456789', '')"/>
358
<xsl:with-param name="text" select="$name"/>
359
<xsl:with-param name="warn" select="false"/>
363
<xsl:value-of select="$name"/>
368
<xsl:template match="template-type-parameter" mode="print.parameter">
369
<xsl:param name="parameter"/>
370
<xsl:param name="is-last"/>
371
<xsl:param name="highlight"/>
374
<xsl:when test="$highlight">
375
<xsl:call-template name="highlight-keyword">
376
<xsl:with-param name="keyword" select="'typename'"/>
380
<xsl:text>typename</xsl:text>
383
<xsl:if test="$parameter/@pack=1">
385
<xsl:when test="$highlight">
386
<xsl:call-template name="highlight-text">
387
<xsl:with-param name="text" select="'...'"/>
391
<xsl:text>...</xsl:text>
395
<xsl:text> </xsl:text>
397
<xsl:call-template name="template.parameter.name">
398
<xsl:with-param name="name" select="$parameter/@name"/>
399
<xsl:with-param name="highlight" select="$highlight"/>
402
<xsl:variable name="def">
404
<xsl:when test="$parameter/@default">
406
<xsl:text>Warning: 'default' attribute of template parameter element is deprecated. Use 'default' element.</xsl:text>
407
<xsl:call-template name="print.warning.context"/>
410
<xsl:when test="$highlight and false()">
411
<xsl:call-template name="source-highlight">
412
<xsl:with-param name="text">
413
<xsl:value-of select="$parameter/@default"/>
418
<xsl:value-of select="$parameter/@default"/>
422
<xsl:when test="$parameter/default">
424
<xsl:when test="$highlight">
426
select="$parameter/default/*|$parameter/default/text()"
430
<xsl:value-of select="string($parameter/default)"/>
437
<xsl:if test="not($def='')">
439
<xsl:when test="$highlight">
440
<xsl:call-template name="highlight-text">
441
<xsl:with-param name="text" select="' = '"/>
445
<xsl:text> = </xsl:text>
449
<xsl:copy-of select="$def"/>
451
<!-- If this is the last parameter, add an extra space to
452
avoid printing >> -->
454
test="$is-last and (substring($def, string-length($def))='>')">
455
<xsl:text> </xsl:text>
460
<xsl:template match="template-nontype-parameter" mode="print.parameter">
461
<xsl:param name="parameter"/>
462
<xsl:param name="is-last"/>
463
<xsl:param name="highlight"/>
466
<xsl:when test="$highlight">
467
<xsl:call-template name="source-highlight">
468
<xsl:with-param name="text">
470
select="$parameter/type/*|$parameter/type/text()"/>
475
<xsl:value-of select="$parameter/type/*|$parameter/type/text()"/>
478
<xsl:if test="$parameter/@pack=1">
480
<xsl:when test="$highlight">
481
<xsl:call-template name="highlight-text">
482
<xsl:with-param name="text" select="'...'"/>
486
<xsl:text>...</xsl:text>
490
<xsl:text> </xsl:text>
492
<xsl:call-template name="template.parameter.name">
493
<xsl:with-param name="name" select="$parameter/@name"/>
494
<xsl:with-param name="highlight" select="$highlight"/>
497
<xsl:variable name="def">
498
<xsl:value-of select="string($parameter/default)"/>
501
<xsl:if test="not($def='')">
503
<xsl:when test="$highlight">
504
<xsl:call-template name="highlight-text">
505
<xsl:with-param name="text" select="' = '"/>
509
<xsl:text> = </xsl:text>
514
<xsl:when test="$highlight">
515
<xsl:apply-templates select="$parameter/default/*|$parameter/default/text()" mode="highlight"/>
518
<xsl:value-of select="$def"/>
522
<!-- If this is the last parameter, add an extra space to
523
avoid printing >> -->
525
test="$is-last and (substring($def, string-length($def))='>')">
526
<xsl:text> </xsl:text>
531
<xsl:template match="template-varargs" mode="print.parameter">
532
<xsl:param name="highlight" select="true()"/>
534
<xsl:when test="$highlight">
535
<xsl:call-template name="highlight-text">
536
<xsl:with-param name="text" select="'...'"/>
540
<xsl:text>...</xsl:text>
545
<xsl:template match="specialization">
546
<xsl:param name="highlight" select="true()"/>
548
<xsl:when test="$highlight">
549
<xsl:call-template name="highlight-text">
550
<xsl:with-param name="text" select="'<'"/>
554
<xsl:text><</xsl:text>
557
<xsl:apply-templates select="template-arg">
558
<xsl:with-param name="highlight" select="$highlight"/>
559
</xsl:apply-templates>
561
<xsl:when test="$highlight">
562
<xsl:call-template name="highlight-text">
563
<xsl:with-param name="text" select="'>'"/>
567
<xsl:text>></xsl:text>
572
<xsl:template match="template-arg">
573
<xsl:param name="highlight" select="true()"/>
574
<xsl:if test="position() > 1">
576
<xsl:when test="$highlight">
577
<xsl:call-template name="highlight-text">
578
<xsl:with-param name="text" select="', '"/>
582
<xsl:text>, </xsl:text>
586
<xsl:apply-templates mode="highlight"/>
587
<xsl:if test="@pack=1">
589
<xsl:when test="$highlight">
590
<xsl:call-template name="highlight-text">
591
<xsl:with-param name="text" select="'...'"/>
595
<xsl:text>...</xsl:text>